Poll() uses the array smallbits that is big enough to hold 32 struct

pollfd's to avoid calling malloc() on small numbers of fd's.  Because
smalltype's members have type char, its address might be misaligned
for a struct pollfd.  Change the array of char to an array of struct
pollfd.

PR:		kern/58214
Submitted by:	Stefan Farfeleder <stefan@fafoe.narf.at>
Reviewed by:	bde (a long time ago)
MFC after:	3 days
This commit is contained in:
Andre Oppermann 2004-08-27 21:23:50 +00:00
parent 5f56967319
commit 2580f4e584
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=134404

View file

@ -848,8 +848,8 @@ poll(td, uap)
struct thread *td;
struct poll_args *uap;
{
caddr_t bits;
char smallbits[32 * sizeof(struct pollfd)];
struct pollfd *bits;
struct pollfd smallbits[32];
struct timeval atv, rtv, ttv;
int error = 0, timo;
u_int ncoll, nfds;
@ -908,7 +908,7 @@ poll(td, uap)
mtx_unlock_spin(&sched_lock);
mtx_unlock(&sellock);
error = pollscan(td, (struct pollfd *)bits, nfds);
error = pollscan(td, bits, nfds);
mtx_lock(&sellock);
if (error || td->td_retval[0])
goto done;