Received: by 2002:a05:6a10:c7d3:0:0:0:0 with SMTP id h19csp1105076pxy; Sun, 15 Aug 2021 09:59:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZFI7DZ6hYjzDFwjweg4PJN9fq9QjcIaTPeJUrugOZMbPFQz/js58fHHjeK21SLDebgf7l X-Received: by 2002:a17:906:6403:: with SMTP id d3mr12226959ejm.37.1629046794423; Sun, 15 Aug 2021 09:59:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629046794; cv=none; d=google.com; s=arc-20160816; b=Q34qY8IdVNaGsUDr/dw/TabVOckpXZb3QFUWG9peZYWg2pD9/oA6QDnNfdOF5hOhgO B40IUs4uucTiUfzH5+oMIYPe/CPAOLN0q9Gj3OBrGxbylSQNR4+TuB2Gq+XeUdsi7VRD woKyriZoDjRWWjx9YRl4n4e8LkFtb9tkB3EyM+F9CFhVPD0VsAwfE/AXC8aFI1visIWv 9zFhYr3fqMsKDEgQsnbXFK/asSVe+3WB6uAentyvBIgcEmBzWw1YswueXV3mVFj47OU9 SsPQuXFPRiiZukgX4/Wfema1p13lvSAJedeqPjDiEHlm32PbQ729KYayAUEanIG9zte8 3F6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=Zb5CmST2HZZpex4W33SsN2CLZL6mrPmabmw4kCKlhAo=; b=GdNHaLjAl4icLje3VQtHoU3sxMf8k6RQlrPuKZ9beSQ0GCKrztAU6LrouWdl7y5VOQ 1ywGGEuOlh5hH5lOwrYpdxWFOPaUDOu5EY15IknWMmD3ZomMcAsUZ8ir72Yq1wSJcwJy neik2QXmeALDfNMW1AXGRUEYW1f5BX+X1+R1sLuRnMspLGgTGBiD5oHko7wEvL46uOLb XssOD5wnUV6B2nLNauYHqW/PER7SOOK26ljOwfMhduo2STfFVP1vgAsnw40ZVFZelfvq 1Udz0RMfDHE4ogR+LTtWzrcm/mo11Ly69VnsBL4DV6i2gHatVx1F7GSQMfa5K8ZL8ih8 NHdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gt16si7873036ejc.735.2021.08.15.09.59.30; Sun, 15 Aug 2021 09:59:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230079AbhHOQ6i (ORCPT + 99 others); Sun, 15 Aug 2021 12:58:38 -0400 Received: from smtprelay0215.hostedemail.com ([216.40.44.215]:39992 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229453AbhHOQ6h (ORCPT ); Sun, 15 Aug 2021 12:58:37 -0400 Received: from omf12.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 8B330182CED28; Sun, 15 Aug 2021 16:58:06 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA id 2BD2B24023A; Sun, 15 Aug 2021 16:58:04 +0000 (UTC) Message-ID: Subject: Re: [PATCH v4] drivers/iio: Remove all strcpy() uses From: Joe Perches To: Len Baker Cc: Andy Shevchenko , Jonathan Cameron , Lars-Peter Clausen , David Laight , Kees Cook , linux-hardening@vger.kernel.org, linux-iio , Linux Kernel Mailing List Date: Sun, 15 Aug 2021 09:58:02 -0700 In-Reply-To: <20210815163639.GA97260@titan> References: <20210814135509.4500-1-len.baker@gmx.com> <20210815163639.GA97260@titan> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: 2BD2B24023A X-Stat-Signature: fk3nqhj5ocpdb55rwicp5umkayeqgrc5 X-Spam-Status: No, score=0.35 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX190y5nwdIZ6qcrkev8JWWtvpp12SQYyul8= X-HE-Tag: 1629046684-898282 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2021-08-15 at 18:36 +0200, Len Baker wrote: > Hi Joe, Hello Len. Don't take this advice too seriously, it's just bikeshedding but it seems to me an unexpected use of a strcmp equivalent in a non performance sensitive path. > On Sun, Aug 15, 2021 at 08:06:45AM -0700, Joe Perches wrote: [] > > bikeshed: > > > > I think this change is less intelligible than the original strcmp. > > So, if I understand correctly you suggest to change the above line for: > ??????????????????????????????else if (strcmp(orient, "0") == 0) Yes. In kernel sources it's about 2:1 in favor of '!strcmp()' over 'strcmp() == 0' $ git grep -P '\!\s*strcmp\b' | wc -l 3457 $ git grep -P '\bstrcmp\s*\([^\)]+\)\s*==\s*0\b' | wc -l 1719 And it's your choice to use one or the other or just your V4 patch. btw, according to godbolt: gcc -O2 doesn't call strcmp and produces the same object code as your byte comparisons. clang 11 calls strcmp regardless of optimization level.