Date: Sun, 26 Apr 1998 13:11:18 +0300 (EEST) From: Ruslan Ermilov <ru@ucb.crimea.ua> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/6420: Patch for rwho(1): better argument parsing + prevents compiler warning Message-ID: <199804261011.NAA14056@relay.ucb.crimea.ua>
index | next in thread | raw e-mail
>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: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Apr 26 03:30:04 PDT 1998
>Last-Modified:
>Originator: Ruslan Ermilov
>Organization:
United Commercial Bank
>Release: FreeBSD 2.2.6-STABLE i386
>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)));
}
>Audit-Trail:
>Unformatted:
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199804261011.NAA14056>
