On Wed, 20 Sep 2017 09:43:39 +0800
Hangbin Liu <liuhang...@gmail.com> wrote:

Thanks for keeping up on this.


> +realloc:
> +     bufp = realloc(buf, buf_len);
> +
> +     if (bufp == NULL) {

Minor personal style issue:
To me, blank lines are like paragraphs in writing.
Code reads better assignment and condition check are next to
each other.

> +recv:
> +     len = recvmsg(fd, msg, flag);
> +
> +     if (len < 0) {
> +             if (errno == EINTR || errno == EAGAIN)
> +                     goto recv;
> +             fprintf(stderr, "netlink receive error %s (%d)\n",
> +                     strerror(errno), errno);
> +             free(buf);
> +             return -errno;
> +     }
> +
> +     if (len == 0) {
> +             fprintf(stderr, "EOF on netlink\n");
> +             free(buf);
> +             return -ENODATA;
> +     }
> +
> +     if (len > buf_len) {
> +             buf_len = len;
> +             flag = 0;
> +             goto realloc;
> +     }
> +
> +     if (flag != 0) {
> +             flag = 0;
> +             goto recv;

Although I programmed in BASIC years ago. I never liked code
with loops via goto. To me it indicates the logic is not well thought
through.  Not sure exactly how to rearrange the control flow, but it
should be possible to rewrite this so that it reads cleaner.

Still think this needs to go through a few more review cycles
before applying.

Reply via email to