On Thu, Jun 06, 2013 at 03:39:38PM +0200, Sylvestre Gallon wrote:
> Hi tech@
> 
> I was currently trying to get the fuse sysctls working when I found a bug
> in sbin/sysctl.c
> 
> If you look at sys/kern/vfs_init.c MOUNT_FUSEFS use the biggest typenum : 18.
> So when the function vfsinit in sbin/sysctl.c gets VFS_MAXTYPENUM it gets 
> 18, but this value will never be reached in the for statement...
> 
> I jump on the occasion to remove all compilation warnings for sysctl.

Hi,

Just curious, how do the variable name changes help any
warrnings?

        nflag -> nf
        name[BUFSIZ] -> str[BUFSIZ]
        devname -> name

... or are they purely variable naming preferences?

--patrick


> 
> Cheers,
> 
> Index: sysctl.c
> ===================================================================
> RCS file: /cvs/src/sbin/sysctl/sysctl.c,v
> retrieving revision 1.189
> diff -u -p -u -p -r1.189 sysctl.c
> --- sysctl.c  16 Apr 2013 22:06:48 -0000      1.189
> +++ sysctl.c  6 Jun 2013 12:07:38 -0000
> @@ -268,7 +268,8 @@ void
>  listall(char *prefix, struct list *lp)
>  {
>       char *cp, name[BUFSIZ];
> -     int lvl2, len;
> +     size_t len;
> +     int lvl2;
>  
>       if (lp->list == NULL)
>               return;
> @@ -861,7 +862,7 @@ parse(char *string, int flags)
>       }
>       if (special & RNDSTATS) {
>               struct rndstats *rndstats = (struct rndstats *)buf;
> -             int i;
> +             size_t i;
>  
>               if (!nflag)
>                       (void)printf("%s%s", string, equ);
> @@ -1025,7 +1026,7 @@ parse_ports(char *portspec, int *port, i
>  
>  void
>  parse_baddynamic(int mib[], size_t len, char *string, void **newvalp,
> -    size_t *newsizep, int flags, int nflag)
> +    size_t *newsizep, int flags, int nf)
>  {
>       static u_int32_t newbaddynamic[DP_MAPSIZE];
>       int port, high_port, baddynamic_loaded = 0, full_list_set = 0;
> @@ -1043,7 +1044,7 @@ parse_baddynamic(int mib[], size_t len, 
>                                   &size, 0, 0) == -1) {
>                                       if (flags == 0)
>                                               return;
> -                                     if (!nflag)
> +                                     if (!nf)
>                                               printf("%s: ", string);
>                                       puts("kernel does contain bad dynamic "
>                                           "port tables");
> @@ -1138,8 +1139,8 @@ vfsinit(void)
>       }
>       mib[2] = VFS_CONF;
>       buflen = sizeof vfc;
> -     for (loc = lastused, cnt = 1; cnt < maxtypenum; cnt++) {
> -             mib[3] = cnt - 1;
> +     for (loc = lastused, cnt = 0; cnt < maxtypenum; cnt++) {
> +             mib[3] = cnt;
>               if (sysctl(mib, 4, &vfc, &buflen, (void *)0, (size_t)0) < 0) {
>                       if (errno == EOPNOTSUPP)
>                               continue;
> @@ -1280,13 +1281,13 @@ sysctl_bios(char *string, char **bufpp, 
>       mib[2] = indx;
>       if (indx == BIOS_DISKINFO) {
>               if (*bufpp == NULL) {
> -                     char name[BUFSIZ];
> +                     char str[BUFSIZ];
>  
>                       /* scan all the bios devices */
>                       for (indx = 0; indx < 256; indx++) {
> -                             snprintf(name, sizeof(name), "%s.%u",
> +                             snprintf(str, sizeof(str), "%s.%u",
>                                   string, indx);
> -                             parse(name, 1);
> +                             parse(str, 1);
>                       }
>                       return (-1);
>               }
> @@ -1782,10 +1783,10 @@ sysctl_forkstat(char *string, char **buf
>  int
>  sysctl_malloc(char *string, char **bufpp, int mib[], int flags, int *typep)
>  {
> -     int indx, stor, i;
> +     int indx, stor;
>       char *name, bufp[SYSCTL_BUFSIZ], *buf, *ptr;
>       struct list lp;
> -     size_t size;
> +     size_t size, i;
>  
>       if (*bufpp == NULL) {
>               listall(string, &kernmalloclist);
> @@ -2282,7 +2283,7 @@ sysctl_tc(char *string, char **bufpp, in
>  int
>  sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
>  {
> -     char *devname, *typename;
> +     char *name, *typename;
>       int dev, numt, i;
>       enum sensor_type type;
>       struct sensordev snsrdev;
> @@ -2312,7 +2313,7 @@ sysctl_sensors(char *string, char **bufp
>        * provided below hw.sensors tree.
>        * The first branch of hw.sensors tree is the device name.
>        */
> -     if ((devname = strsep(bufpp, ".")) == NULL) {
> +     if ((name = strsep(bufpp, ".")) == NULL) {
>               warnx("%s: incomplete specification", string);
>               return (-1);
>       }
> @@ -2325,11 +2326,11 @@ sysctl_sensors(char *string, char **bufp
>                       if (errno == ENOENT)
>                               break;
>               }
> -             if (strcmp(devname, snsrdev.xname) == 0)
> +             if (strcmp(name, snsrdev.xname) == 0)
>                       break;
>       }
> -     if (strcmp(devname, snsrdev.xname) != 0) {
> -             warnx("%s: sensor device not found: %s", string, devname);
> +     if (strcmp(name, snsrdev.xname) != 0) {
> +             warnx("%s: sensor device not found: %s", string, name);
>               return (-1);
>       }
>       if (*bufpp == NULL) {
> @@ -2586,6 +2587,7 @@ struct emulname {
>  } *emul_names;
>  int  emul_num, nemuls;
>  int  emul_init(void);
> +int  emulcmp(const void *, const void *);
>  
>  int
>  sysctl_emul(char *string, char *newval, int flags)
> 

Reply via email to