[Toybox] [PATCH] Fix vmstat for large machines.

Rob Landley rob at landley.net
Wed Mar 21 11:28:31 PDT 2018


On 03/16/2018 01:35 PM, enh wrote:
> -    } else if (!(p = strafter(toybuf, vmstuff[i]))) goto error;
> -    if (1 != sscanf(p, "%"PRIu64"%n", new++, &j)) goto error;
> +    } else if (!(p = strafter(file, vmstuff[i]))) {
> +      error_exit("No %sin %s", vmstuff[i], name);
> +    }
> +    if (1 != sscanf(p, "%"PRIu64"%n", new++, &j)) {
> +      error_exit("Bad %sin %s: %s", vmstuff[i], name, p);
> +    }
>      p += j;
>    }
> -
> -  return;
> -
> -error:
> -  error_exit("No %sin %s\n", vmstuff[i], name);
> +  free(file);

Is the difference between a successfully opened /proc file not having an
expected field and having no parseable data after the field identifier really
significant enough to require two distinct error messages?

Both boil down to "Your kernel is broken, something is _really_ wrong."

Also, "vmstat -n" is never showing the header, rather than showing it once. Is
this a bug or behavior somebody wanted?


Rob



More information about the Toybox mailing list