sysctl warns6 cleanup

看板DFBSD_submit作者時間21年前 (2005/01/09 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/10 (看更多)
--HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Attached. -- / Peter Schuller, InfiDyne Technologies HB PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller@infidyne.com>' Key retrieval: Send an E-Mail to getpgpkey@scode.org E-Mail: peter.schuller@infidyne.com Web: http://www.scode.org --HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sysctl.patch" --- sbin/sysctl/Makefile.orig 2005-01-02 03:41:02.000000000 +0000 +++ sbin/sysctl/Makefile 2005-01-08 07:54:09.000000000 +0000 @@ -4,5 +4,6 @@ PROG= sysctl MAN= sysctl.8 +WARNS?= 6 .include <bsd.prog.mk> --- sbin/sysctl/sysctl.c.orig 2005-01-02 03:41:06.000000000 +0000 +++ sbin/sysctl/sysctl.c 2005-01-08 08:02:27.000000000 +0000 @@ -405,7 +405,7 @@ */ struct _foo { int majdev; - char *name; + const char *name; } maj2name[] = { { 30, "ad" }, { 0, "wd" }, @@ -459,7 +459,8 @@ show_var(int *oid, int nlen) { u_char buf[BUFSIZ], *val, *p; - char name[BUFSIZ], *fmt, *sep; + char name[BUFSIZ], *fmt; + const char *sep; int qoid[CTL_MAXNAME+2]; int i; size_t j, len; @@ -518,20 +519,20 @@ case 'A': if (!nflag) printf("%s%s", name, sep); - printf("%.*s", len, p); + printf("%.*s", (int)len, p); return (0); case 'I': if (!nflag) printf("%s%s", name, sep); fmt++; - val = ""; + strcpy(val, ""); while (len >= sizeof(int)) { if(*fmt == 'U') printf("%s%u", val, *(unsigned int *)p); else printf("%s%d", val, *(int *)p); - val = " "; + strcpy(val, " "); len -= sizeof(int); p += sizeof(int); } @@ -545,13 +546,13 @@ if (!strcmp(name, "machdep.guessed_bootdev")) return machdep_bootdev(*(unsigned long *)p); #endif - val = ""; + strcpy(val, ""); while (len >= sizeof(long)) { if(*fmt == 'U') printf("%s%lu", val, *(unsigned long *)p); else printf("%s%ld", val, *(long *)p); - val = " "; + strcpy(val, " "); len -= sizeof(long); p += sizeof(long); } @@ -567,13 +568,13 @@ if (!nflag) printf("%s%s", name, sep); fmt++; - val = ""; + strcpy(val, ""); while (len >= sizeof(int64_t)) { if(*fmt == 'U') printf("%s%llu", val, (long long)*(u_int64_t *)p); else printf("%s%lld", val, (long long)*(int64_t *)p); - val = " "; + strcpy(val, " "); len -= sizeof(int64_t); p += sizeof(int64_t); } @@ -644,7 +645,7 @@ l2 /= sizeof(int); - if (l2 < len) + if (l2 < (size_t)len) return 0; for (i = 0; i < len; i++) --HlL+5n6rz5pIUxbD--
文章代碼(AID): #11u20K00 (DFBSD_submit)
討論串 (同標題文章)
文章代碼(AID): #11u20K00 (DFBSD_submit)