From 5f47bf1a212b957009a85207338ee5b1d6ec6340 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 3 Jun 2014 23:36:56 -0700 Subject: Print which option was in error along with usage message Signed-off-by: Alan Coopersmith --- configure.ac | 2 +- xvinfo.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index b1bc647..1592c22 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,7 @@ XORG_MACROS_VERSION(1.8) XORG_DEFAULT_OPTIONS # Checks for pkg-config packages -PKG_CHECK_MODULES(XVINFO, [xv x11 xproto >= 7.0.17]) +PKG_CHECK_MODULES(XVINFO, [xv x11 xproto >= 7.0.25]) AC_CONFIG_FILES([ Makefile diff --git a/xvinfo.c b/xvinfo.c index 951ab22..891c8c2 100644 --- a/xvinfo.c +++ b/xvinfo.c @@ -12,10 +12,11 @@ static char *progname; -static void _X_NORETURN +static void _X_NORETURN _X_COLD PrintUsage(void) { - fprintf(stderr, "Usage: %s [-display host:dpy] [-short] [-version]\n", progname); + fprintf(stderr, "Usage: %s [-display host:dpy] [-short] [-version]\n", + progname); exit(0); } @@ -43,8 +44,12 @@ main(int argc, char *argv[]) if (argc != 1) { for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-display")) { - disname = argv[i + 1]; - i++; + if (++i >= argc) { + fprintf (stderr, "%s: missing argument to -display\n", + progname); + PrintUsage(); + } + disname = argv[i]; } else if (!strcmp(argv[i], "-short")) shortmode = 1; @@ -53,6 +58,8 @@ main(int argc, char *argv[]) exit(0); } else { + fprintf (stderr, "%s: unrecognized argument '%s'\n", + progname, argv[i]); PrintUsage(); } } -- cgit v1.2.3