Re: sysctl warns6 cleanup

看板DFBSD_submit作者時間21年前 (2005/01/09 05:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串9/10 (看更多)
On Sat, Jan 08, 2005 at 12:14:40PM -0800, Chris Pressey wrote: > @@ -355,7 +353,7 @@ > * may seem, there are various conflicting requirements. > */ > > -static int > +static size_t > name2oid(char *name, int *oidp) > { > int oid[2]; > @@ -367,14 +365,14 @@ > > j = CTL_MAXNAME * sizeof(int); > i = sysctl(oid, 2, oidp, &j, name, strlen(name)); > - if (i < 0) > - return i; > + if (i < 0) > + errx(1, "unknown oid '%s'", name); > j /= sizeof(int); > return (j); > } Eliminate this helper function and use sysctlnametomib from libc. > @@ -616,10 +615,11 @@ > } > > static int > -sysctl_all (int *oid, int len) > +sysctl_all(int *oid, size_t len) > { > int name1[22], name2[22]; > int i, j; > + unsigned int k; size_t k ? It seems you can merge i and j, name it retval or so :) Rest is fine. Joerg
文章代碼(AID): #11u4eJ00 (DFBSD_submit)
討論串 (同標題文章)
文章代碼(AID): #11u4eJ00 (DFBSD_submit)