* [PATCHv2] misc: kgdbts: Fix restrict error
@ 2018-09-11 17:44 Laura Abbott
2018-09-18 23:14 ` Daniel Thompson
0 siblings, 1 reply; 2+ messages in thread
From: Laura Abbott @ 2018-09-11 17:44 UTC (permalink / raw)
To: Jason Wessel, Daniel Thompson, Arnd Bergmann
Cc: Laura Abbott, Greg Kroah-Hartman, kgdb-bugreport, linux-kernel
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 avoid the extra copy and put the parsing closer to
the actual location.
Signed-off-by: Laura Abbott <labbott@redhat.com>
---
v2: Refactored to move the verbose setting into kgbts_run_tests per
suggestion of Daniel Thompson
---
drivers/misc/kgdbts.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 6193270e7b3d..de20bdaa148d 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -985,6 +985,12 @@ static void kgdbts_run_tests(void)
int nmi_sleep = 0;
int i;
+ verbose = 0;
+ if (strstr(config, "V1"))
+ verbose = 1;
+ if (strstr(config, "V2"))
+ verbose = 2;
+
ptr = strchr(config, 'F');
if (ptr)
fork_test = simple_strtol(ptr + 1, NULL, 10);
@@ -1068,13 +1074,6 @@ static int kgdbts_option_setup(char *opt)
return -ENOSPC;
}
strcpy(config, opt);
-
- verbose = 0;
- if (strstr(config, "V1"))
- verbose = 1;
- if (strstr(config, "V2"))
- verbose = 2;
-
return 0;
}
@@ -1086,9 +1085,6 @@ static int configure_kgdbts(void)
if (!strlen(config) || isspace(config[0]))
goto noconfig;
- err = kgdbts_option_setup(config);
- if (err)
- goto noconfig;
final_ack = 0;
run_plant_and_detach_test(1);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCHv2] misc: kgdbts: Fix restrict error
2018-09-11 17:44 [PATCHv2] misc: kgdbts: Fix restrict error Laura Abbott
@ 2018-09-18 23:14 ` Daniel Thompson
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Thompson @ 2018-09-18 23:14 UTC (permalink / raw)
To: Laura Abbott
Cc: Jason Wessel, Arnd Bergmann, Greg Kroah-Hartman, kgdb-bugreport,
linux-kernel
On Tue, Sep 11, 2018 at 10:44:03AM -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 avoid the extra copy and put the parsing closer to
> the actual location.
>
> Signed-off-by: Laura Abbott <labbott@redhat.com>
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
> ---
> v2: Refactored to move the verbose setting into kgbts_run_tests per
> suggestion of Daniel Thompson
> ---
> drivers/misc/kgdbts.c | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
> index 6193270e7b3d..de20bdaa148d 100644
> --- a/drivers/misc/kgdbts.c
> +++ b/drivers/misc/kgdbts.c
> @@ -985,6 +985,12 @@ static void kgdbts_run_tests(void)
> int nmi_sleep = 0;
> int i;
>
> + verbose = 0;
> + if (strstr(config, "V1"))
> + verbose = 1;
> + if (strstr(config, "V2"))
> + verbose = 2;
> +
> ptr = strchr(config, 'F');
> if (ptr)
> fork_test = simple_strtol(ptr + 1, NULL, 10);
> @@ -1068,13 +1074,6 @@ static int kgdbts_option_setup(char *opt)
> return -ENOSPC;
> }
> strcpy(config, opt);
> -
> - verbose = 0;
> - if (strstr(config, "V1"))
> - verbose = 1;
> - if (strstr(config, "V2"))
> - verbose = 2;
> -
> return 0;
> }
>
> @@ -1086,9 +1085,6 @@ static int configure_kgdbts(void)
>
> if (!strlen(config) || isspace(config[0]))
> goto noconfig;
> - err = kgdbts_option_setup(config);
> - if (err)
> - goto noconfig;
>
> final_ack = 0;
> run_plant_and_detach_test(1);
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-18 23:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11 17:44 [PATCHv2] misc: kgdbts: Fix restrict error Laura Abbott
2018-09-18 23:14 ` Daniel Thompson
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).