Commit 1ecfe2b8 authored by Laura Abbott's avatar Laura Abbott Committed by Kleber Sacilotto de Souza

misc: kgdbts: Fix restrict error

BugLink: https://bugs.launchpad.net/bugs/1853881

[ Upstream commit fa0218ef ]

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: default avatarLaura Abbott <labbott@redhat.com>
Acked-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent ab27517d
...@@ -979,6 +979,12 @@ static void kgdbts_run_tests(void) ...@@ -979,6 +979,12 @@ static void kgdbts_run_tests(void)
int nmi_sleep = 0; int nmi_sleep = 0;
int i; int i;
verbose = 0;
if (strstr(config, "V1"))
verbose = 1;
if (strstr(config, "V2"))
verbose = 2;
ptr = strchr(config, 'F'); ptr = strchr(config, 'F');
if (ptr) if (ptr)
fork_test = simple_strtol(ptr + 1, NULL, 10); fork_test = simple_strtol(ptr + 1, NULL, 10);
...@@ -1062,13 +1068,6 @@ static int kgdbts_option_setup(char *opt) ...@@ -1062,13 +1068,6 @@ static int kgdbts_option_setup(char *opt)
return -ENOSPC; return -ENOSPC;
} }
strcpy(config, opt); strcpy(config, opt);
verbose = 0;
if (strstr(config, "V1"))
verbose = 1;
if (strstr(config, "V2"))
verbose = 2;
return 0; return 0;
} }
...@@ -1080,9 +1079,6 @@ static int configure_kgdbts(void) ...@@ -1080,9 +1079,6 @@ static int configure_kgdbts(void)
if (!strlen(config) || isspace(config[0])) if (!strlen(config) || isspace(config[0]))
goto noconfig; goto noconfig;
err = kgdbts_option_setup(config);
if (err)
goto noconfig;
final_ack = 0; final_ack = 0;
run_plant_and_detach_test(1); run_plant_and_detach_test(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment