[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 06/16] qemu-img: Clean up global variable shadowing
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 06/16] qemu-img: Clean up global variable shadowing |
Date: |
Wed, 4 Oct 2023 14:00:09 +0200 |
Fix:
qemu-img.c:247:46: error: declaration shadows a variable in the global scope
[-Werror,-Wshadow]
static bool is_valid_option_list(const char *optarg)
^
qemu-img.c:265:53: error: declaration shadows a variable in the global scope
[-Werror,-Wshadow]
static int accumulate_options(char **options, char *optarg)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14:
note: previous declaration is here
extern char *optarg; /* getopt(3) external variables */
^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
qemu-img.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index a48edb7101..6068ab0d27 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -235,25 +235,25 @@ void help(void)
}
/*
- * Is @optarg safe for accumulate_options()?
+ * Is @list safe for accumulate_options()?
* It is when multiple of them can be joined together separated by ','.
- * To make that work, @optarg must not start with ',' (or else a
+ * To make that work, @list must not start with ',' (or else a
* separating ',' preceding it gets escaped), and it must not end with
* an odd number of ',' (or else a separating ',' following it gets
* escaped), or be empty (or else a separating ',' preceding it can
* escape a separating ',' following it).
*
*/
-static bool is_valid_option_list(const char *optarg)
+static bool is_valid_option_list(const char *list)
{
- size_t len = strlen(optarg);
+ size_t len = strlen(list);
size_t i;
- if (!optarg[0] || optarg[0] == ',') {
+ if (!list[0] || list[0] == ',') {
return false;
}
- for (i = len; i > 0 && optarg[i - 1] == ','; i--) {
+ for (i = len; i > 0 && list[i - 1] == ','; i--) {
}
if ((len - i) % 2) {
return false;
@@ -262,19 +262,19 @@ static bool is_valid_option_list(const char *optarg)
return true;
}
-static int accumulate_options(char **options, char *optarg)
+static int accumulate_options(char **options, char *list)
{
char *new_options;
- if (!is_valid_option_list(optarg)) {
- error_report("Invalid option list: %s", optarg);
+ if (!is_valid_option_list(list)) {
+ error_report("Invalid option list: %s", list);
return -1;
}
if (!*options) {
- *options = g_strdup(optarg);
+ *options = g_strdup(list);
} else {
- new_options = g_strdup_printf("%s,%s", *options, optarg);
+ new_options = g_strdup_printf("%s,%s", *options, list);
g_free(*options);
*options = new_options;
}
--
2.41.0
- Re: [PATCH v3 13/16] semihosting/arm-compat: Clean up local variable shadowing, (continued)
[PATCH v3 14/16] softmmu/vl: Clean up global variable shadowing, Philippe Mathieu-Daudé, 2023/10/04
[PATCH v3 15/16] sysemu/tpm: Clean up global variable shadowing, Philippe Mathieu-Daudé, 2023/10/04
[PATCH v3 16/16] trace/control: Clean up global variable shadowing, Philippe Mathieu-Daudé, 2023/10/04
[PATCH v3 06/16] qemu-img: Clean up global variable shadowing,
Philippe Mathieu-Daudé <=
[PATCH v3 10/16] ui/cocoa: Clean up global variable shadowing, Philippe Mathieu-Daudé, 2023/10/04
[PATCH v3 12/16] util/guest-random: Clean up global variable shadowing, Philippe Mathieu-Daudé, 2023/10/04
Re: [PATCH v3 00/16] (few more) Steps towards enabling -Wshadow, Richard Henderson, 2023/10/04
Re: [PATCH v3 00/16] (few more) Steps towards enabling -Wshadow, Markus Armbruster, 2023/10/06
Re: [PATCH v3 00/16] (few more) Steps towards enabling -Wshadow, Markus Armbruster, 2023/10/06