Skip to contentSkip to conversation

tabled: check argument of -D better

PATCH In review Pete Zaitcev 1 participant 1 message Apr 18, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 11/12 tabled: check argument of -D better

The atoi() really does not cut it, as I discovered when I supplied -D -E to tabled. Other arguments may benefit from such checking too, but -D is unique in that nothing gets logged in case of this mistake. So let's just add it here for now; others will at least report something.

---
 server/server.c |    4 ++++
 1 file changed, 4 insertions(+)

commit b340bd6bbf9d7a82b69ad620f43799b616348a45

Author: Master <[email protected]>
Date:   Sat Apr 17 20:40:12 2010 -0600

Deconfuse -D -E.

server/server.c +4 -0
index e1b0dbe..a28965c 100644
@@ -184,6 +184,10 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
 		tabled_srv.config = arg;
 		break;
 	case 'D':
+		if (arg[0] == '-') {
+			fprintf(stderr, "Option -D requires an argument\n");
+			argp_usage(state);
+		}
 		v = atoi(arg);
 		if (v < 0 || v > 2) {
 			fprintf(stderr, "invalid debug level: '%s'\n", arg);