[PATCH] tests: commandhelper: Accept POLLNVAL on macOS

Andrea Bolognani abologna at redhat.com
Wed Oct 7 16:57:21 UTC 2020


On Wed, 2020-10-07 at 15:20 +0300, Roman Bolshakov wrote:
>          for (i = 0; i < numpollfds; i++) {
> -            if (fds[i].revents & (POLLIN | POLLHUP | POLLERR)) {
> +            if (fds[i].revents & (POLLIN | POLLHUP | POLLERR |
> +# ifdef __APPLE__
> +                                  /*
> +                                   * poll() on /dev/null will return POLLNVAL
> +                                   */
> +                                  POLLNVAL)) {
> +# else
> +                                  0)) {
> +# endif

The fix seems legit, but having a preprocessor directive in the
middle of a function call doesn't look great. Can you rewrite this
along the lines of

  for (i = 0; i < numpollfds; i++) {
      short revents = POLLIN | POLLHUP | POLLERR;
  
  # ifdef __APPLE__
      /* On macOS, poll() on devices will return POLLNVAL */
      revents |= POLLNVAL;
  # endif
  
      if (fds[i].revents & revents) {
          /* ... */
      }
  }

please?

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list