[PATCH] scanner: Fix reported executable name to 'wayland-scanner'

Jonas Ådahl jadahl at gmail.com
Sat Jun 4 06:15:57 UTC 2016


On Fri, Jun 03, 2016 at 06:34:38PM -0500, Yong Bakos wrote:
> Hi,
> 
> On Jun 2, 2016, at 8:16 PM, Jonas Ådahl <jadahl at gmail.com> wrote:
> > 
> > On Thu, Jun 02, 2016 at 02:42:44PM -0700, Bryce Harrington wrote:
> >> 'wayland-scanner -v' (correctly) reports the program as named
> >> "wayland-scanner", but 'wayland-scanner -h' was inconsistent, referring
> >> to it as './scanner'.
> >> 
> >> Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
> 
> Bryce, good catch! But...
> 
> 
> > I guess we could also pass argv and use argv[0], but this works as well.
> > 
> > Reviewed-by: Jonas Ådahl <jadahl at gmail.com>
> 
> 
> I don't follow this at all, because...
> 
> 
> >> ---
> >> src/scanner.c | 4 ++--
> >> 1 file changed, 2 insertions(+), 2 deletions(-)
> >> 
> >> diff --git a/src/scanner.c b/src/scanner.c
> >> index 5f06e8e..ae2326f 100644
> >> --- a/src/scanner.c
> >> +++ b/src/scanner.c
> >> @@ -57,8 +57,8 @@ enum side {
> >> static int
> >> usage(int ret)
> >> {
> >> -	fprintf(stderr, "usage: ./scanner [OPTION] [client-header|server-header|code]"
> >> -		" [input_file output_file]\n");
> >> +	fprintf(stderr, "usage: wayland-scanner [OPTION] [client-header|server-header|code]"
> >> +		" [input_file output_file]\n", argv[0]);
> 
> argv is out of scope here in `usage`. This won't compile without changing
> the parameter list, and the passed args at all call sites.

Right. argv would have to be passed around. Or using the GNU way. My RB
was just about the correctness of this patch; it improves the current
situation, thus can be landed. Future improvements aren't hindered by
that.


Jonas

> 
> Also, shouldn't the diff be more like (notice the %s format specifier):
> 
> +	fprintf(stderr, "usage: %s [OPTION] [client-header|server-header|code]"
> +		" [input_file output_file]\n", argv[0]);
> 
> 
> >> 	fprintf(stderr, "\n");
> >> 	fprintf(stderr, "Converts XML protocol descriptions supplied on "
> >> 			"stdin or input file to client\n"
> >> -- 
> >> 1.9.1
> 
> Regards,
> yong
> 
> 


More information about the wayland-devel mailing list