From simon@comsys.ntu-kpi.kiev.ua  Tue May 30 13:16:54 2006
Return-Path: <simon@comsys.ntu-kpi.kiev.ua>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id EED2016A425
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 May 2006 13:16:53 +0000 (UTC)
	(envelope-from simon@comsys.ntu-kpi.kiev.ua)
Received: from comsys.ntu-kpi.kiev.ua (comsys.ntu-kpi.kiev.ua [195.245.194.142])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 449AE43D48
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 May 2006 13:16:40 +0000 (GMT)
	(envelope-from simon@comsys.ntu-kpi.kiev.ua)
Received: from pm513-1.comsys.ntu-kpi.kiev.ua (pm513-1.comsys.ntu-kpi.kiev.ua [10.18.52.101])
	(authenticated bits=0)
	by comsys.ntu-kpi.kiev.ua (8.13.6/8.13.6) with ESMTP id k4UDHQsq007040
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL)
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 30 May 2006 16:17:26 +0300 (EEST)
Received: by pm513-1.comsys.ntu-kpi.kiev.ua (Postfix, from userid 1001)
	id DC1AB5C023; Tue, 30 May 2006 16:16:29 +0300 (EEST)
Message-Id: <20060530131629.GA2438@pm513-1.comsys.ntu-kpi.kiev.ua>
Date: Tue, 30 May 2006 16:16:29 +0300
From: Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
To: FreeBSD-gnats-submit@freebsd.org
Subject: [patch] Update for regression/sockets/unix_cmsg

>Number:         98141
>Category:       bin
>Synopsis:       [patch] Update for regression/sockets/unix_cmsg
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 30 13:20:22 GMT 2006
>Closed-Date:    Wed May 31 08:13:03 GMT 2006
>Last-Modified:  Wed May 31 08:13:03 GMT 2006
>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:

From: Maxim Konovalov <maxim@macomnet.ru>
To: Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
Cc: bug-followup@freebsd.org
Subject: Re: bin/98141: [patch] Update for regression/sockets/unix_cmsg
Date: Tue, 30 May 2006 17:40:32 +0400 (MSD)

 > o	Use PRIdMAX macro for outputting intmax_t values.
 
 What is it for?  I see nothing is using this macro in the base system
 and it is defined as "jd" on all our platforms.
 
 -- 
 Maxim Konovalov
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Wed May 31 08:12:13 UTC 2006 
State-Changed-Why:  
Committed apart from PRIdMAX delta.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=98141 
>Unformatted:
