[PATCH] to select.c (and an apology)

almesber en lrc.di.epfl.ch almesber en lrc.di.epfl.ch
Lun Ene 31 00:52:55 CST 2000


willy en 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 en 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 en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda