Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4347999imm; Tue, 11 Sep 2018 10:29:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbNmiud3LV0M7fCCDZd26oFujKXw1F1WrWnDxHY2IbCCrlAxt+CwCdw+upKm6Ghxm//cLj1 X-Received: by 2002:a63:9409:: with SMTP id m9-v6mr29686368pge.13.1536686946860; Tue, 11 Sep 2018 10:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536686946; cv=none; d=google.com; s=arc-20160816; b=fHY/HKxlr6vfC1y6NLZHQGCVVSOXyrdyX7oMWqm/hMZE5ddlRnyHZGCxLQQvlQBGQk WrFPNyT8+0I0MD+9sfg0QN2TBaHnZ7LrNKCIz3YhTEwUjSPtQWXPRJFohy00Iup24Q1A cHSbIG5D/0k2A8+kym0Fo4w67gVmNjSs2VmYDDkG8qOaDg6zEL2SmjiTuZ3ZPE07lftk 1RVbYHymrmXtJwrFoYTV7jd9dvS+oiSQXOeWwk/e6qmGMNfeG+T6HTTP8cSDNURnmoM3 rqmMQw7wmuv3KEId5xavWLzaM3D1tEP25cfNp4r16aMDuMBGXBEVpyXlK1MeCokkoL6i xq1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=aOL5qmgeiuDuN0JS8Zgz+3H3T6uZdosMbUhAIM4NdZM=; b=JG+cOtIixCUW92YOztpgQewTkli1iV8IwXfX6m5CCm1+2M2z/TV/GVFqyztRn/R6vd ynIqRsDmbXby57sgrzaNguiJGDqAd2WODBsuTjNJdtx/a7yOTXKAGmIP7p60NJma5Wtz a2+Sa48Lj/9IxQZptssXDKfljMzYpSs8DoipcmEyf5z5GkW7PTP+ES6e8Dm+Zm1vxOga sZFr6YVfNp4m25y+wBXJKIYcuFDpFuEtAKK4oTJKgkiIS8RHIrHAOCdqjd0WQVX09UiI QNsJBI5zP1ZunGdTbR7Uib9tE//XBd43skw71P0U3AECWjQ7mTZ6VFVoRi33uPH2FxN2 0+nA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7-v6si21322972plk.122.2018.09.11.10.28.47; Tue, 11 Sep 2018 10:29:06 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbeIKW2o (ORCPT + 99 others); Tue, 11 Sep 2018 18:28:44 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:45451 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726943AbeIKW2o (ORCPT ); Tue, 11 Sep 2018 18:28:44 -0400 Received: by mail-qt0-f194.google.com with SMTP id g44-v6so29047148qtb.12 for ; Tue, 11 Sep 2018 10:28:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=aOL5qmgeiuDuN0JS8Zgz+3H3T6uZdosMbUhAIM4NdZM=; b=gEpsEOuUsEyVD9CX0RKwqxvbWHZh2v2NSBU/Wy+CETal+te8TNxZZqYjeUIti9ja+p XXHx9qJAxkOJpVUEYIj0hdPxEIEUILxzPaaPQGHpiTX177qIttMGoOwhi4erpX0qiGPt mSiT/iDZYgo1AUWRptXf/Zrqz6pggAzJRcYjBbE1C3zIhfteSc6HEdZn38DZcMHh/lLv HBWP/2x8P3lnqR/ueMQ4XZ4ZI2MZOemMrAk7QCVAO0UPoISNS69MYTtcSAT0hdQt7E/E zde67QL2qE/BWuUvvoT/AtRtoKWq1CK5ACINzChgTE463uxXuTZFi1T9FWb7yX2g+WDu STbw== X-Gm-Message-State: APzg51CYXEf5z5HbfvSwL+eYvvXGqxPl3pAljyiEq7CNrOasyBuvIDbV lhOYQWqc2c4HmmSn2QkOfWggrFjW27w= X-Received: by 2002:a0c:c503:: with SMTP id x3-v6mr19123088qvi.82.1536686903730; Tue, 11 Sep 2018 10:28:23 -0700 (PDT) Received: from ?IPv6:2601:602:9802:a8dc::42c3? ([2601:602:9802:a8dc::42c3]) by smtp.gmail.com with ESMTPSA id n8-v6sm10463841qte.25.2018.09.11.10.28.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 10:28:22 -0700 (PDT) Subject: Re: [PATCH] misc: kgdbts: Fix restrict error To: Daniel Thompson Cc: Jason Wessel , Arnd Bergmann , Greg Kroah-Hartman , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20180910230456.9220-1-labbott@redhat.com> <20180911091940.roriqov64ayk7mfs@holly.lan> From: Laura Abbott Message-ID: <8d149627-6550-4a5c-b136-6acdb713b724@redhat.com> Date: Tue, 11 Sep 2018 10:28:20 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180911091940.roriqov64ayk7mfs@holly.lan> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/11/2018 02:19 AM, Daniel Thompson wrote: > 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? > > I'll go ahead and send a v2 > 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 >>