Re: [patch] poll.2: tfix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Enke,

On 4/4/23 03:40, Enke Chen wrote:
> diff --git a/man2/poll.2 b/man2/poll.2
> index 4e26e62d4..5d2fa622d 100644
> --- a/man2/poll.2
> +++ b/man2/poll.2
> @@ -604,7 +604,7 @@ main(int argc, char *argv[])
> 
>          /* Deal with array returned by poll(). */
> 
> -        for (nfds_t j = 0; j < nfds; j++) {
> +        for (nfds_t j = 0; j < ready; j++) {

This is not correct.  The array is of size nfds.  ready is
just the number of entries in the array that have been changed,
but there's no information about the order in which they'll
appear.

If you compile the program with the current code, you'll be
able to verify that it works.  But with this patch, I believe
it will stop working.

Thanks,
Alex

>              if (pfds[j].revents != 0) {
>                  printf("  fd=%d; events: %s%s%s\en", pfds[j].fd,
>                         (pfds[j].revents & POLLIN)  ? "POLLIN "  : "",
> 

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux