qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wshadow: Better name for 'optarg'?


From: Warner Losh
Subject: Re: Wshadow: Better name for 'optarg'?
Date: Wed, 4 Oct 2023 07:14:07 -0600



On Wed, Oct 4, 2023, 4:16 AM Daniel P. Berrangé <berrange@redhat.com> wrote:
On Wed, Oct 04, 2023 at 12:05:04PM +0200, Philippe Mathieu-Daudé wrote:
> Hi,
>
> I'm getting a bunch of errors for 'optarg' declared in <unistd.h>:
>
> NAME
>      getopt – get option character from command line argument list
>
> LIBRARY
>      Standard C Library (libc, -lc)
>
> SYNOPSIS
>      #include <unistd.h>
>
>      extern char *optarg;
>
>
> qom/object_interfaces.c:262:53: error: declaration shadows a variable in the
> global scope [-Werror,-Wshadow]
> ObjectOptions *user_creatable_parse_str(const char *optarg, Error **errp)

snip

> Do we want to clean those? Any good name suggestion?

Yes.  any of "argval", "opts", "optstr", "optval".

For the parsing in bsd-user I just removed the variable entirely and removed the updating of its value since the parsing code was trying to do what getopt also did...

Warner 

With regards,
Daniel
--
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



reply via email to

[Prev in Thread] Current Thread [Next in Thread]