linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laura Abbott <labbott@redhat.com>
To: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jason Wessel <jason.wessel@windriver.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kgdb-bugreport@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] misc: kgdbts: Fix restrict error
Date: Tue, 11 Sep 2018 10:28:20 -0700	[thread overview]
Message-ID: <8d149627-6550-4a5c-b136-6acdb713b724@redhat.com> (raw)
In-Reply-To: <20180911091940.roriqov64ayk7mfs@holly.lan>

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 <labbott@redhat.com>
>> ---
>>   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
>>


      reply	other threads:[~2018-09-11 17:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 23:04 [PATCH] misc: kgdbts: Fix restrict error Laura Abbott
2018-09-11  9:19 ` Daniel Thompson
2018-09-11 17:28   ` Laura Abbott [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8d149627-6550-4a5c-b136-6acdb713b724@redhat.com \
    --to=labbott@redhat.com \
    --cc=arnd@arndb.de \
    --cc=daniel.thompson@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jason.wessel@windriver.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).