bin/98141: [patch] Update for regression/sockets/unix_cmsg
Andrey Simonenko
simon at comsys.ntu-kpi.kiev.ua
Tue May 30 06:20:28 PDT 2006
>Number: 98141
>Category: bin
>Synopsis: [patch] Update for regression/sockets/unix_cmsg
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Tue May 30 13:20:22 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Andrey Simonenko
>Release: FreeBSD 7.0-CURRENT
>Organization:
>Environment:
>Description:
I updated sockets/unix_cmsg regression tests:
o Let getopt(3) report errors in command line arguments.
o If something is wrong with options, then output short
usage help message.
o Use PRIdMAX macro for outputting intmax_t values.
o Output errstr returned from strtonum(3).
>How-To-Repeat:
>Fix:
--- unix_cmsg.c.orig Mon May 29 21:40:55 2006
+++ unix_cmsg.c Tue May 30 15:43:00 2006
@@ -162,12 +162,14 @@
* Output the help message (-h switch).
*/
static void
-usage(void)
+usage(int quick)
{
const struct test_func *test_func;
- fprintf(stderr, "Usage: %s [-dhz] [-t <socktype>] [testno]\n\n", __progname);
- fprintf(stderr, " Options are:\n\
+ fprintf(stderr, "Usage: %s [-dhz] [-t <socktype>] [testno]\n", __progname);
+ if (quick)
+ return;
+ fprintf(stderr, "\n Options are:\n\
-d\t\t\tOutput debugging information\n\
-h\t\t\tOutput this help message and exit\n\
-t <socktype>\t\tRun test only for the given socket type:\n\
@@ -314,15 +316,14 @@
int opt, dgramflag, streamflag;
u_int testno1, testno2;
- opterr = 0;
dgramflag = streamflag = 0;
- while ((opt = getopt(argc, argv, ":dht:z")) != -1)
+ while ((opt = getopt(argc, argv, "dht:z")) != -1)
switch (opt) {
case 'd':
debug = 1;
break;
case 'h':
- usage();
+ usage(0);
return (EX_OK);
case 't':
if (strcmp(optarg, "stream") == 0)
@@ -335,14 +336,10 @@
case 'z':
no_control_data = 1;
break;
- case ':':
- errx(EX_USAGE, "option -%c requires an argument", optopt);
- /* NOTREACHED */
case '?':
- errx(EX_USAGE, "invalid switch -%c", optopt);
- /* NOTREACHED */
default:
- errx(EX_SOFTWARE, "unexpected option -%c", optopt);
+ usage(1);
+ return (EX_USAGE);
}
if (optind < argc) {
@@ -350,7 +347,7 @@
errx(EX_USAGE, "too many arguments");
testno1 = strtonum(argv[optind], 0, UINT_MAX, &errstr);
if (errstr != NULL)
- errx(EX_USAGE, "wrong test number");
+ errx(EX_USAGE, "wrong test number: %s", errstr);
} else
testno1 = 0;
@@ -1560,7 +1557,7 @@
timeval = (const struct timeval *)CMSG_DATA(cmptr);
- dbgmsg(("timeval tv_sec %jd, tv_usec %jd",
+ dbgmsg(("timeval tv_sec %"PRIdMAX", tv_usec %"PRIdMAX,
(intmax_t)timeval->tv_sec, (intmax_t)timeval->tv_usec));
if ((cmptr = CMSG_NXTHDR(&msg, cmptr)) != NULL) {
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list