On Sun, Nov 11, 2018 at 12:24:51PM +0100, Klemens Nanni wrote:
> On Sat, Nov 03, 2018 at 08:41:22PM +0100, Klemens Nanni wrote:
> > Simpler and without ugly `goto fail'. `value.addr` is typed XPointer
> > which is just a char pointer.
> >
> > Zap linter hints while here.
> Bump.
Comments in-line, mostly nits.
With those addressed, ok cheloha@
> [...]
>
> Index: xidle.c
> ===================================================================
> RCS file: /cvs/xenocara/app/xidle/xidle.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 xidle.c
> --- xidle.c 6 Sep 2018 07:21:34 -0000 1.6
> +++ xidle.c 11 Nov 2018 11:22:47 -0000
> @@ -187,14 +187,10 @@ action(struct xinfo *xi, char **args)
> switch (fork()) {
> case -1:
> err(1, "fork");
> - /* NOTREACHED */
> -
> case 0:
> setsid();
> execv(*args, args);
> exit(1);
> - /* NOTREACHED */
> -
This should print a warning and then _exit(2), not exit(3).
I know you're "already here" but I might put that in a different
patch. Don't know if it "fits" with the other patch content.
Choice is yours, though maybe someone else will have an opinion.
> default:
> wait(&dumb);
> XSync(xi->dpy, True);
> @@ -259,6 +255,7 @@ void
> parse_opts(int argc, char **argv, Display **dpy, int *area, int *delay,
> int *timeout, int *position, char **args)
> {
> + const char *errstr;
> char **ap, *program = PATH_PROG;
> char *display, *p;
> XrmDatabase tdb, rdb = NULL;
> @@ -276,7 +273,6 @@ parse_opts(int argc, char **argv, Displa
> *dpy = XOpenDisplay(display);
> if (!*dpy) {
> errx(1, "Unable to open display %s", XDisplayName(display));
> - /* NOTREACHED */
> }
For consistency with the rest of the program's style, drop the braces
from the if-statement here.
>
> /* Get server resources database. */
> @@ -297,29 +293,26 @@ parse_opts(int argc, char **argv, Displa
> __progname, &argc, argv);
> if (argc > 1) {
> usage();
> - /* NOTREACHED */
> }
Same thing here.
> if (getres(&value, rdb, "area", "Area")) {
> - *area = strtol((char *)value.addr, &p, 10);
> - if (*p || *area < 1) {
> -fail: errx(1, "illegal value -- %s", (char
> *)value.addr);
> - /* NOTREACHED */
> - }
> + *area = strtonum(value.addr, 0, INT_MAX, &errstr);
> + if (errstr)
> + errx(1, "area is %s: %s", errstr, value.addr);
> }
The only serious issue: the original check was *area < 1, but now you
allow *area to be 0. Typo?
> if (getres(&value, rdb, "delay", "Delay")) {
> - *delay = strtol((char *)value.addr, &p, 10);
> - if (*p || *delay < 0)
> - goto fail;
> + *delay = strtonum(value.addr, 0, INT_MAX, &errstr);
> + if (errstr)
> + errx(1, "delay is %s: %s", errstr, value.addr);
> }
> if (getres(&value, rdb, "position", "Position")) {
> *position = str2pos((char *)value.addr);
> if (!*position)
> - goto fail;
> + errx(1, "position is invalid: %s", value.addr);
> }
> if (getres(&value, rdb, "timeout", "Timeout")) {
> - *timeout = strtol((char *)value.addr, &p, 10);
> - if (*p || *timeout < 0)
> - goto fail;
> + *timeout = strtonum(value.addr, 0, INT_MAX, &errstr);
> + if (errstr)
> + errx(1, "timeout is %s: %s", errstr, value.addr);
> }
> if (getres(&value, rdb, "program", "Program")) {
> /* Should be the last :) */
> @@ -454,6 +447,4 @@ main(int argc, char **argv)
> break;
> }
> }
> -
> - /* NOTREACHED */
> }
>