[openib-general] Re: [patch] userspace/management: ARGBEGIN() ->getopt() conversion for diags

Michael S. Tsirkin mst at mellanox.co.il
Wed Jan 18 07:32:04 PST 2006


Quoting r. Sasha Khapyorsky <sashak at voltaire.com>:
> Subject: [patch] userspace/management: ARGBEGIN() ->getopt() conversion for diags
> 
> Hi Hal,
> 
> Diag utils are converted to getopt(). It is just basically tested,
> so please report bugs (if any).
> 
> Sasha.
> 
> 
> This converts diag utils to more standard getopt() using instead of
> AGRBEGIN() buggy macros. Unused now ARGBEGIN() related code is
> removed from libibcommon.
> 

Good stuff.

> Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
>
> Index: diags/src/ibtracert.c
> ===================================================================
> --- diags/src/ibtracert.c	(revision 5057)
> +++ diags/src/ibtracert.c	(working copy)
> @@ -41,6 +41,7 @@
>  #include <unistd.h>
>  #include <stdarg.h>
>  #include <ctype.h>
> +#include <getopt.h>
>  #include <netinet/in.h>
>  
>  #include <common.h>
> @@ -54,6 +55,8 @@
>  int force;
>  FILE *f;
>  
> +static char *argv0 = "ibtracert";
> +

Is there some reason to initialize it?
You seem to set it to argv[0] below ...

>  #undef DEBUG
>  #define	DEBUG	if (ibdebug || verbose) IBWARN
>  #define	VERBOSE	if (ibdebug || verbose > 1) IBWARN
> @@ -726,7 +729,7 @@
>  		basename++;
>  
>  	fprintf(stderr, "Usage: %s [-d(ebug) -v(erbose) -D(irect_path_addrs) -G(uid_addrs) -v(erbose) -n(o_info) -C ca_name -P hca_port "
> -			"-s smlid -t timeout_ms -m mlid] <src-addr> <dest-addr>\n",
> +			"-s smlid -t(imeout) timeout_ms -m mlid] <src-addr> <dest-addr>\n",
>  			basename);
>  	fprintf(stderr, "\n\tUnicast examples:\n");
>  	fprintf(stderr, "\t\t%s 4 16\t\t\t# show path between lids 4 and 16\n", basename);
> @@ -753,57 +756,85 @@
>  	char *ca = 0;
>  	int ca_port = 0;
>  
> +	static char const str_opts[] = "C:P:t:s:m:dvfDGnVhu";
> +	static const struct option long_opts[] = {
> +		{ "C", 1, 0, 'C'},
> +		{ "P", 1, 0, 'P'},
> +		{ "debug", 0, 0, 'd'},
> +		{ "verbose", 0, 0, 'v'},
> +		{ "force", 0, 0, 'f'},
> +		{ "Direct_path_addrs", 0, 0, 'D'},
> +		{ "Guid_addrs", 0, 0, 'G'},
> +		{ "no_info", 0, 0, 'n'},
> +		{ "timeout", 1, 0, 't'},
> +		{ "s", 1, 0, 's'},
> +		{ "m", 1, 0, 'm'},
> +		{ "Version", 0, 0, 'V'},
> +		{ "help", 0, 0, 'h'},
> +		{ "usage", 0, 0, 'u'},
> +		{ }
> +	};
> +
> +	argv0 = argv[0];
> +
>  	f = stderr;




-- 
MST



More information about the general mailing list