From nobody@FreeBSD.org  Sun May 27 07:09:55 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 5E4BD16A400
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 27 May 2007 07:09:55 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id 4FCCF13C447
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 27 May 2007 07:09:55 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l4R79tSZ065636
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 27 May 2007 07:09:55 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l4R79tli065635;
	Sun, 27 May 2007 07:09:55 GMT
	(envelope-from nobody)
Message-Id: <200705270709.l4R79tli065635@www.freebsd.org>
Date: Sun, 27 May 2007 07:09:55 GMT
From: Ighighi<ighighi@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH]: make quot(8) use getopt(3) and show usage() if no arguments
X-Send-Pr-Version: www-3.0

>Number:         113049
>Category:       bin
>Synopsis:       [patch] [request] make quot(8) use getopt(3) and show usage() if no arguments
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 27 07:10:02 GMT 2007
>Closed-Date:    
>Last-Modified:  Sun Mar 09 13:06:29 UTC 2008
>Originator:     Ighighi
>Release:        6.2-STABLE
>Organization:
>Environment:
FreeBSD orion 6.2-STABLE FreeBSD 6.2-STABLE #0: Thu May 24 09:18:16 VET 2007     root@orion:/usr/obj/usr/src/sys/CUSTOM  i386
>Description:
This patch adds getopt(3) support for quot(8) and to display usage with
no arguments present.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- src/usr.sbin/quot/quot.c.orig	Sat Oct 14 23:28:54 2006
+++ src/usr.sbin/quot/quot.c	Sun May 27 02:48:20 2007
@@ -616,42 +616,48 @@
 	char dev[MNAMELEN + 1];
 	char *nm;
 	int cnt;
+	int ch;
+
+	if (argc == 1)
+		usage();
 	
 	func = douser;
 #ifndef	COMPAT
 	header = getbsize(&headerlen,&blocksize);
 #endif
-	while (--argc > 0 && **++argv == '-') {
-		while (*++*argv) {
-			switch (**argv) {
-			case 'n':
-				func = donames;
-				break;
-			case 'c':
-				func = dofsizes;
-				break;
-			case 'a':
-				all = 1;
-				break;
-			case 'f':
-				count = 1;
-				break;
-			case 'h':
-				estimate = 1;
-				break;
+
+	while ((ch = getopt(argc, argv, "acfhknv")) != -1) {
+		switch (ch) {
+		case 'a':
+			all = 1;
+			break;
+		case 'c':
+			func = dofsizes;
+			break;
+		case 'f':
+			count = 1;
+			break;
+		case 'h':
+			estimate = 1;
+			break;
 #ifndef	COMPAT
-			case 'k':
-				blocksize = 1024;
-				break;
+		case 'k':
+			blocksize = 1024;
+			break;
 #endif	/* COMPAT */
-			case 'v':
-				unused = 1;
-				break;
-			default:
-				usage();
-			}
+		case 'n':
+			func = donames;
+			break;
+		case 'v':
+			unused = 1;
+			break;
+		default:
+			usage();
 		}
 	}
+	argc -= optind;
+	argv += optind;
+
 	if (all) {
 		cnt = getmntinfo(&mp,MNT_NOWAIT);
 		for (; --cnt >= 0; mp++) {


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Sun Mar 9 13:06:20 UTC 2008 
Responsible-Changed-Why:  
Over to maintainers. 

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