diff options
author | 2007-07-05 09:42:26 +0000 | |
---|---|---|
committer | 2007-07-05 09:42:26 +0000 | |
commit | 73de99158af79981abb326f963b7893d8450e159 (patch) | |
tree | 2d1a74912318dd97984520f19e606c7c0111c45b | |
parent | From FreeBSD: (diff) | |
download | wireguard-openbsd-73de99158af79981abb326f963b7893d8450e159.tar.xz wireguard-openbsd-73de99158af79981abb326f963b7893d8450e159.zip |
use a more traditional while() instead of for() for getopt().
sync usage() to the man page.
format string fixes.
complain about failed calloc()'s instead of exiting silently.
ok pry@,reyk@
-rw-r--r-- | usr.sbin/hoststated/hoststated.c | 6 | ||||
-rw-r--r-- | usr.sbin/hoststated/parse.y | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/parse.y | 12 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.c | 6 |
4 files changed, 20 insertions, 16 deletions
diff --git a/usr.sbin/hoststated/hoststated.c b/usr.sbin/hoststated/hoststated.c index ab22e2c296f..c31588dacce 100644 --- a/usr.sbin/hoststated/hoststated.c +++ b/usr.sbin/hoststated/hoststated.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hoststated.c,v 1.37 2007/06/19 06:29:20 pyr Exp $ */ +/* $OpenBSD: hoststated.c,v 1.38 2007/07/05 09:42:26 thib Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -105,7 +105,7 @@ usage(void) { extern char *__progname; - fprintf(stderr, "%s [-dnv] [-f file]\n", __progname); + fprintf(stderr, "%s [-dnv] [-D macro=value] [-f file]\n", __progname); exit(1); } @@ -127,7 +127,7 @@ main(int argc, char *argv[]) debug = 0; conffile = CONF_FILE; - for (;(c = getopt(argc, argv, "dD:nf:v")) != -1;) { + while ((c = getopt(argc, argv, "dD:nf:v")) != -1) { switch (c) { case 'd': debug = 1; diff --git a/usr.sbin/hoststated/parse.y b/usr.sbin/hoststated/parse.y index 637b76175ed..65be41149af 100644 --- a/usr.sbin/hoststated/parse.y +++ b/usr.sbin/hoststated/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.49 2007/05/31 18:58:09 pyr Exp $ */ +/* $OpenBSD: parse.y,v 1.50 2007/07/05 09:42:26 thib Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -158,7 +158,7 @@ http_type : STRING { } else if (strcmp("http", $1) == 0) { $$ = 0; } else { - yyerror("invalid check type: $1", $1); + yyerror("invalid check type: %s", $1); free($1); YYERROR; } @@ -171,7 +171,7 @@ proto_type : TCP { $$ = RELAY_PROTO_TCP; } if (strcmp("http", $1) == 0) { $$ = RELAY_PROTO_HTTP; } else { - yyerror("invalid protocol type: $1", $1); + yyerror("invalid protocol type: %s", $1); free($1); YYERROR; } @@ -396,7 +396,7 @@ table : TABLE STRING { if (!strcmp(tb->conf.name, $2)) break; if (tb != NULL) { - yyerror("table %s defined twice"); + yyerror("table %s defined twice", $2); free($2); YYERROR; } @@ -1415,8 +1415,10 @@ parse_config(const char *filename, int opts) if ((conf = calloc(1, sizeof(*conf))) == NULL || (conf->tables = calloc(1, sizeof(*conf->tables))) == NULL || - (conf->services = calloc(1, sizeof(*conf->services))) == NULL) + (conf->services = calloc(1, sizeof(*conf->services))) == NULL) { + warn("cannot allocate memory"); return (NULL); + } last_host_id = last_table_id = last_service_id = last_proto_id = last_relay_id = 0; diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index 637b76175ed..65be41149af 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.49 2007/05/31 18:58:09 pyr Exp $ */ +/* $OpenBSD: parse.y,v 1.50 2007/07/05 09:42:26 thib Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -158,7 +158,7 @@ http_type : STRING { } else if (strcmp("http", $1) == 0) { $$ = 0; } else { - yyerror("invalid check type: $1", $1); + yyerror("invalid check type: %s", $1); free($1); YYERROR; } @@ -171,7 +171,7 @@ proto_type : TCP { $$ = RELAY_PROTO_TCP; } if (strcmp("http", $1) == 0) { $$ = RELAY_PROTO_HTTP; } else { - yyerror("invalid protocol type: $1", $1); + yyerror("invalid protocol type: %s", $1); free($1); YYERROR; } @@ -396,7 +396,7 @@ table : TABLE STRING { if (!strcmp(tb->conf.name, $2)) break; if (tb != NULL) { - yyerror("table %s defined twice"); + yyerror("table %s defined twice", $2); free($2); YYERROR; } @@ -1415,8 +1415,10 @@ parse_config(const char *filename, int opts) if ((conf = calloc(1, sizeof(*conf))) == NULL || (conf->tables = calloc(1, sizeof(*conf->tables))) == NULL || - (conf->services = calloc(1, sizeof(*conf->services))) == NULL) + (conf->services = calloc(1, sizeof(*conf->services))) == NULL) { + warn("cannot allocate memory"); return (NULL); + } last_host_id = last_table_id = last_service_id = last_proto_id = last_relay_id = 0; diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index a72279016bd..2de941c0367 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.37 2007/06/19 06:29:20 pyr Exp $ */ +/* $OpenBSD: relayd.c,v 1.38 2007/07/05 09:42:26 thib Exp $ */ /* * Copyright (c) 2006 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -105,7 +105,7 @@ usage(void) { extern char *__progname; - fprintf(stderr, "%s [-dnv] [-f file]\n", __progname); + fprintf(stderr, "%s [-dnv] [-D macro=value] [-f file]\n", __progname); exit(1); } @@ -127,7 +127,7 @@ main(int argc, char *argv[]) debug = 0; conffile = CONF_FILE; - for (;(c = getopt(argc, argv, "dD:nf:v")) != -1;) { + while ((c = getopt(argc, argv, "dD:nf:v")) != -1) { switch (c) { case 'd': debug = 1; |