From ru@ucb.crimea.ua  Sun Apr 26 03:26:21 1998
Received: from relay.ucb.crimea.ua (relay.ucb.crimea.ua [194.93.177.113])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id DAA12262
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 26 Apr 1998 03:11:33 -0700 (PDT)
          (envelope-from ru@ucb.crimea.ua)
Received: (from ru@localhost)
	by relay.ucb.crimea.ua (8.8.8/8.8.8) id NAA14056;
	Sun, 26 Apr 1998 13:11:18 +0300 (EEST)
	(envelope-from ru)
Message-Id: <199804261011.NAA14056@relay.ucb.crimea.ua>
Date: Sun, 26 Apr 1998 13:11:18 +0300 (EEST)
From: Ruslan Ermilov <ru@ucb.crimea.ua>
Reply-To: ru@ucb.crimea.ua
To: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Patch for rwho(1): better argument parsing + prevents compiler warning
X-Send-Pr-Version: 3.2

>Number:         6420
>Category:       bin
>Synopsis:       Patch for rwho(1): better argument parsing + prevents compiler warning
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Apr 26 03:30:04 PDT 1998
>Closed-Date:    Sun May 3 16:26:34 PDT 1998
>Last-Modified:  Sun May  3 16:27:08 PDT 1998
>Originator:     Ruslan Ermilov
>Release:        FreeBSD 2.2.6-STABLE i386
>Organization:
United Commercial Bank
>Environment:

	Both -current and -stable.

>Description:

1. Rwho doesn't check it's syntax (usage: rwho [-a])
2. Rwho compiles with warning about function qsort().

>How-To-Repeat:

1. Run ``rwho 1 2 3''.
2. rwho.c: In function `main':
   rwho.c:143: warning: passing arg 4 of `qsort' from incompatible pointer type

>Fix:

Apply this patch to both -stable and -current:

Index: rwho.c
===================================================================
RCS file: /usr/FreeBSD-CVS/src/usr.bin/rwho/rwho.c,v
retrieving revision 1.11
diff -u -r1.11 rwho.c
--- rwho.c	1997/08/08 12:20:24	1.11
+++ rwho.c	1998/04/26 09:59:39
@@ -80,7 +80,7 @@
 int	aflg;
 
 static void usage __P((void));
-int utmpcmp __P((struct myutmp *, struct myutmp *));
+int utmpcmp __P((const void *, const void *));
 
 int
 main(argc, argv)
@@ -106,6 +106,12 @@
 		default:
 			usage();
 		}
+	argc -= optind;
+	argv += optind;
+
+	if (argc != 0)
+		usage();
+
 	if (chdir(_PATH_RWHODIR) || (dirp = opendir(".")) == NULL)
 		err(1, "%s", _PATH_RWHODIR);
 	mp = myutmp;
@@ -189,17 +195,19 @@
 	exit(1);
 }
 
+#define	MYUTMP(a)	((struct myutmp *)(a))
+
 int
 utmpcmp(u1, u2)
-	struct myutmp *u1, *u2;
+	const void *u1, *u2;
 {
 	int rc;
 
-	rc = strncmp(u1->myutmp.out_name, u2->myutmp.out_name, sizeof(u2->myutmp.out_name));
+	rc = strncmp(MYUTMP(u1)->myutmp.out_name, MYUTMP(u2)->myutmp.out_name, sizeof(MYUTMP(u2)->myutmp.out_name));
 	if (rc)
 		return (rc);
-	rc = strcmp(u1->myhost, u2->myhost);
+	rc = strcmp(MYUTMP(u1)->myhost, MYUTMP(u2)->myhost);
 	if (rc)
 		return (rc);
-	return (strncmp(u1->myutmp.out_line, u2->myutmp.out_line, sizeof(u2->myutmp.out_line)));
+	return (strncmp(MYUTMP(u1)->myutmp.out_line, MYUTMP(u2)->myutmp.out_line, sizeof(MYUTMP(u2)->myutmp.out_line)));
 }

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: steve 
State-Changed-When: Sun May 3 16:26:34 PDT 1998 
State-Changed-Why:  
Patch committed to both -current and -stable.  Thanks! 
>Unformatted:
