lkml.org 
[lkml]   [2000]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] to select.c (and an apology)
willy@thepuffingroup.com wrote:
> On Mon, Jan 31, 2000 at 03:56:03AM +0100, Patrick Mau wrote:
>> +/*
>> fds = (struct pollfd **)kmalloc(
>> (1 + (nfds - 1) / POLLFD_PER_PAGE) * sizeof(struct pollfd *),
>> GFP_KERNEL);

> (nfds * sizeof(void *) + POLLFD_PER_PAGE - 1) / POLLFD_PER_PAGE

Assuming that a struct pollfd * points to a page of pollfds, and fds is
an array of pointers, this is still wrong, e.g. assume nfds = 1,
sizeof(void *) = 4, POLLFD_PER_PAGE any value >= 2.

The original version yields a correct result and even seems a bit clearer,
unless nfds-1 becomes unsigned. In that case, something like

(nfds+POLLFD_PER_PAGE-1)/POLLFD_PER_PAGE*sizeof(struct pollfd *)

should help.

- Werner

--
_________________________________________________________________________
/ Werner Almesberger, ICA, EPFL, CH werner.almesberger@ica.epfl.ch /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.064 / U:1.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site