Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3808315imm; Tue, 11 Sep 2018 02:21:54 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb8G1T3cWOkwotgjHPVuW7MJZ7wEfkssKG7rh6+5zHgFMneho4/GVPqlTxNlX9t5r2jjGXl X-Received: by 2002:a17:902:d808:: with SMTP id a8-v6mr26301549plz.68.1536657714189; Tue, 11 Sep 2018 02:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536657714; cv=none; d=google.com; s=arc-20160816; b=cvZpJ/H+cRUf9avSNMYeeJBB5Z4WeYi2Tw54djGAxfCuN+vDA2Z4/Kecf19gHwpK9z BeAQeYGVWDUwcPr6MectRabo4wmStkdHJsAOwsr24BgCmXIJCxqTDPvR3OTWbYZhBSTp eEk4FqhBm2/Fujf8XcTRURpY7TttULVmCILRxjsvASQ0TZHm58QUHpgiXdZ05LjI+9B5 +XAXpwSRFe4XLz2J2hR9VCv6syB7gFh4VXnc+5Omm/PV04GwG9b3+TaFtS1r1eA+Yw40 Y6BMj/rjb/uNBvwrjB8t0smcZdUkwA1Y4a/O0i8awg6gdcUPYDF7GJpKKaUlNCRZjWxD zf6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Xu4uwE5DpLsfzsByG8NPhpM1yc6NbOJRpycgkbvJuJ8=; b=ka8dYoVKrEihwvAgX7FIfuF4iONVtWyxlgI9j273jp5dhbgJmJkeCI+xNuwIbvYDed L5zgDbYmb8Nm+B5Jn/u4RhYP+l5qGeWjeHZwu7bQNssO/z5fFWeVf1mbIpWodTJpsTte L6ta8TCM8Irujqe+Kut6AuG21hVBEJZEHAjVwX+HlD2AEx7pKkUMU5EUV9t6RnMjcFdr HdWlaaJNU0wVEHlIfupmi7Lj5cbzejbwoVE4EPwWWZhUsRdk7V0MsKdMa07BdlAAgY+t BldpkGRSOp0kQEz+O4fbTJ73RbYTPhw1fX53jC6OqrQ8/eNJ7NG4uIU5TEeRnmILp5pq ls0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=avmxF8Dp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si20048932pfu.79.2018.09.11.02.21.37; Tue, 11 Sep 2018 02:21:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=avmxF8Dp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbeIKOSK (ORCPT + 99 others); Tue, 11 Sep 2018 10:18:10 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39801 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726564AbeIKOSK (ORCPT ); Tue, 11 Sep 2018 10:18:10 -0400 Received: by mail-wr1-f66.google.com with SMTP id s14-v6so15963654wrw.6 for ; Tue, 11 Sep 2018 02:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Xu4uwE5DpLsfzsByG8NPhpM1yc6NbOJRpycgkbvJuJ8=; b=avmxF8DpCmKgdWXxLfJ/AWJUwTf1i7MhJcJOHW1gdZRoWmyXsFvYfvhcQOMNfmUIh7 D/YeYiialsqh02baRNPKE28lBhpcu8MhLOMfTDO+kTF6YjIopUrk/LQ1W6Vl6J5qIoWe 3Y8ccmByOXrq+WhM04Bsc+e97oVPadQi+4/hQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=Xu4uwE5DpLsfzsByG8NPhpM1yc6NbOJRpycgkbvJuJ8=; b=EnM4cRrPh0usMIpC99G8tIB03VbLRAkCH4b1iw0VGG/Qe0wHl4KXP5SnIxBSVuOK+s SAaMK3NUK39It/u9c4z9anfkGarLupwJPfydLsCTHolOUrqp0LNGClh3PMeLvat8s1Kv 8ssQKlW3K709PMaDoHSnQVpcpVyb7UImeRllK6x1PBJdP5C75tnQhGHxL5yumn/CHK2D 3Trm3cZrkPHA5RZkWDfe0MCCBdZVuxPWWKsefaqniar/tUxjJ65+Iuap6idptdxsZgh8 oj+Z6293enU2BmN39lAr8a8EwiVvfbGOOqsz5+bMyMJNe4o5HJ6GNxBpgWffUZbZlumx LPIQ== X-Gm-Message-State: APzg51A2fdPsXQt5pxV9wdXpzwWMtU9HAxVLBAg9RSwRjJuxDdsa5fDk bTj/ozZlpQVo1NWqFyJK0TdlJQ== X-Received: by 2002:a5d:490b:: with SMTP id x11-v6mr16989463wrq.114.1536657583638; Tue, 11 Sep 2018 02:19:43 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id d1-v6sm36022148wrc.52.2018.09.11.02.19.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Sep 2018 02:19:42 -0700 (PDT) Date: Tue, 11 Sep 2018 10:19:40 +0100 From: Daniel Thompson To: Laura Abbott Cc: Jason Wessel , Arnd Bergmann , Greg Kroah-Hartman , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] misc: kgdbts: Fix restrict error Message-ID: <20180911091940.roriqov64ayk7mfs@holly.lan> References: <20180910230456.9220-1-labbott@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180910230456.9220-1-labbott@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 10, 2018 at 04:04:56PM -0700, Laura Abbott wrote: > kgdbts current fails when compiled with restrict: > > drivers/misc/kgdbts.c: In function ‘configure_kgdbts’: > drivers/misc/kgdbts.c:1070:2: error: ‘strcpy’ source argument is the same as destination [-Werror=restrict] > strcpy(config, opt); > ^~~~~~~~~~~~~~~~~~~ > > As the error says, config is being used in both the source and destination. > Refactor the code to only do the copy when needed. > > Signed-off-by: Laura Abbott > --- > drivers/misc/kgdbts.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > > diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c > index 6193270e7b3d..4447ad68ea39 100644 > --- a/drivers/misc/kgdbts.c > +++ b/drivers/misc/kgdbts.c > @@ -1061,20 +1061,23 @@ static void kgdbts_run_tests(void) > configured = 0; > } > > -static int kgdbts_option_setup(char *opt) > +static void kgdbts_set_verbose(void) > { > - if (strlen(opt) >= MAX_CONFIG_LEN) { > - printk(KERN_ERR "kgdbts: config string too long\n"); > - return -ENOSPC; > - } > - strcpy(config, opt); > - > verbose = 0; > if (strstr(config, "V1")) > verbose = 1; > if (strstr(config, "V2")) > verbose = 2; > +} > > +static int kgdbts_option_setup(char *opt) > +{ > + if (strlen(opt) >= MAX_CONFIG_LEN) { > + printk(KERN_ERR "kgdbts: config string too long\n"); > + return -ENOSPC; > + } > + strcpy(config, opt); > + kgdbts_set_verbose(); I know this is honouring the existing code paths but I think kgdbts_set_verbose() is redundant here. Directly setting up verbose from kgdbts_run_tests() where the rest of the config string is parsed should be sufficient. Having said that I don't want to bounce perfectly correct fixes just because they could have done more. Do you want to send a v2 or prefer me to put further clean up on my TODO list? Daniel. > return 0; > } > > @@ -1086,9 +1089,7 @@ static int configure_kgdbts(void) > > if (!strlen(config) || isspace(config[0])) > goto noconfig; > - err = kgdbts_option_setup(config); > - if (err) > - goto noconfig; > + kgdbts_set_verbose(); > > final_ack = 0; > run_plant_and_detach_test(1); > -- > 2.17.1 >