[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180910230456.9220-1-labbott@redhat.com>
Date: Mon, 10 Sep 2018 16:04:56 -0700
From: Laura Abbott <labbott@...hat.com>
To: Jason Wessel <jason.wessel@...driver.com>,
Daniel Thompson <daniel.thompson@...aro.org>,
Arnd Bergmann <arnd@...db.de>
Cc: Laura Abbott <labbott@...hat.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
kgdb-bugreport@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: [PATCH] misc: kgdbts: Fix restrict error
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@...hat.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();
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
Powered by blists - more mailing lists