[PATCH v3 15/16] sysemu/tpm: Clean up global variable shadowing

Philippe Mathieu-Daudé posted 16 patches 2 years, 4 months ago
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, John Snow <jsnow@redhat.com>, Jason Wang <jasowang@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, "Alex Bennée" <alex.bennee@linaro.org>, Stefan Berger <stefanb@linux.vnet.ibm.com>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Mads Ynddal <mads@ynddal.dk>, Peter Maydell <peter.maydell@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Akihiko Odaki <akihiko.odaki@daynix.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>
[PATCH v3 15/16] sysemu/tpm: Clean up global variable shadowing
Posted by Philippe Mathieu-Daudé 2 years, 4 months ago
Fix:

  softmmu/tpm.c:178:59: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  int tpm_config_parse(QemuOptsList *opts_list, const 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>
---
 include/sysemu/tpm.h | 2 +-
 softmmu/tpm.c        | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index 66e3b45f30..1ee568b3b6 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -17,7 +17,7 @@
 
 #ifdef CONFIG_TPM
 
-int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);
+int tpm_config_parse(QemuOptsList *opts_list, const char *optstr);
 int tpm_init(void);
 void tpm_cleanup(void);
 
diff --git a/softmmu/tpm.c b/softmmu/tpm.c
index 578563f05a..7164ea7ff1 100644
--- a/softmmu/tpm.c
+++ b/softmmu/tpm.c
@@ -175,15 +175,15 @@ int tpm_init(void)
  * Parse the TPM configuration options.
  * To display all available TPM backends the user may use '-tpmdev help'
  */
-int tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
+int tpm_config_parse(QemuOptsList *opts_list, const char *optstr)
 {
     QemuOpts *opts;
 
-    if (!strcmp(optarg, "help")) {
+    if (!strcmp(optstr, "help")) {
         tpm_display_backend_drivers();
         return -1;
     }
-    opts = qemu_opts_parse_noisily(opts_list, optarg, true);
+    opts = qemu_opts_parse_noisily(opts_list, optstr, true);
     if (!opts) {
         return -1;
     }
-- 
2.41.0


Re: [PATCH v3 15/16] sysemu/tpm: Clean up global variable shadowing
Posted by Stefan Berger 2 years, 4 months ago
On 10/4/23 08:00, Philippe Mathieu-Daudé wrote:
> Fix:
>
>    softmmu/tpm.c:178:59: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>    int tpm_config_parse(QemuOptsList *opts_list, const 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>

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>



> ---
>   include/sysemu/tpm.h | 2 +-
>   softmmu/tpm.c        | 6 +++---
>   2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
> index 66e3b45f30..1ee568b3b6 100644
> --- a/include/sysemu/tpm.h
> +++ b/include/sysemu/tpm.h
> @@ -17,7 +17,7 @@
>
>   #ifdef CONFIG_TPM
>
> -int tpm_config_parse(QemuOptsList *opts_list, const char *optarg);
> +int tpm_config_parse(QemuOptsList *opts_list, const char *optstr);
>   int tpm_init(void);
>   void tpm_cleanup(void);
>
> diff --git a/softmmu/tpm.c b/softmmu/tpm.c
> index 578563f05a..7164ea7ff1 100644
> --- a/softmmu/tpm.c
> +++ b/softmmu/tpm.c
> @@ -175,15 +175,15 @@ int tpm_init(void)
>    * Parse the TPM configuration options.
>    * To display all available TPM backends the user may use '-tpmdev help'
>    */
> -int tpm_config_parse(QemuOptsList *opts_list, const char *optarg)
> +int tpm_config_parse(QemuOptsList *opts_list, const char *optstr)
>   {
>       QemuOpts *opts;
>
> -    if (!strcmp(optarg, "help")) {
> +    if (!strcmp(optstr, "help")) {
>           tpm_display_backend_drivers();
>           return -1;
>       }
> -    opts = qemu_opts_parse_noisily(opts_list, optarg, true);
> +    opts = qemu_opts_parse_noisily(opts_list, optstr, true);
>       if (!opts) {
>           return -1;
>       }