From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F266C433EF for ; Fri, 13 May 2022 18:59:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381728AbiEMS7O (ORCPT ); Fri, 13 May 2022 14:59:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240694AbiEMS7N (ORCPT ); Fri, 13 May 2022 14:59:13 -0400 Received: from mail.enpas.org (zhong.enpas.org [IPv6:2a03:4000:2:537::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5ECC852E51; Fri, 13 May 2022 11:59:11 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 0668AFFCE9; Fri, 13 May 2022 18:59:09 +0000 (UTC) Date: Fri, 13 May 2022 20:59:07 +0200 From: Max Staudt To: Vincent Mailhol Cc: Wolfgang Grandegger , Marc Kleine-Budde , linux-can@vger.kernel.org, Greg Kroah-Hartman , Oliver Neukum , linux-kernel@vger.kernel.org Subject: Re: [PATCH v6] can, tty: can327 CAN/ldisc driver for ELM327 based OBD-II adapters Message-ID: <20220513205907.6d5473ff.max@enpas.org> In-Reply-To: References: <20220512182921.193462-1-max@enpas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-can@vger.kernel.org On Fri, 13 May 2022 15:31:20 +0900 Vincent Mailhol wrote: > On Fri. 13 May 2022 at 11:38, Vincent Mailhol > wrote: [...] > > > + case ELM327_STATE_RECEIVING: > > > + /* Find delimiting feedback lines. */ > > > + for (len = 0; > > > + (len < elm->rxfill) && (elm->rxbuf[len] != > > > '\r'); > > > + len++) { > > > + /* empty loop */ > > > > Question of taste but would prefer a while look with the len++ in > > the body (if you prefer to do as above, no need to argue, just keep > > it like it is). > > Actually, what about this? > > len = strnchr(elm->rxbuf, elm->rxfill, '\r'); Actually I'd use memchr() if anything, but not really here. I do end up using the actual index. And since both strchr() and mrmchr() return pointers, I'd rather avoid them because I prefer to use indices whenever possible. Max