[PATCH:smproxy 6/7] Print which option was in error along with usage message

Alan Coopersmith alan.coopersmith at oracle.com
Sun Nov 24 09:35:26 PST 2013


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 smproxy.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/smproxy.c b/smproxy.c
index 7c59f16..3ceb880 100644
--- a/smproxy.c
+++ b/smproxy.c
@@ -1168,17 +1168,27 @@ main (int argc, char *argv[])
 		continue;
 
 	      case 'c':				/* -clientId */
-		if (++i >= argc) goto usage;
+		if (++i >= argc) {
+		    fprintf (stderr, "%s: -clientId requires an argument\n",
+			     argv[0]);
+		    goto usage;
+		}
 		client_id = argv[i];
 		continue;
 
 	      case 'r':				/* -restore */
-		if (++i >= argc) goto usage;
+		if (++i >= argc) {
+		    fprintf (stderr, "%s: -restore requires an argument\n",
+			     argv[0]);
+		    goto usage;
+		}
 		restore_filename = argv[i];
 		continue;
 	    }
 	}
 
+	fprintf (stderr, "%s: unrecognized argument: %s\n", argv[0], argv[i]);
+
     usage:
 
 	fprintf (stderr,
-- 
1.7.9.2



More information about the xorg-devel mailing list