From: Ian Jackson Date: Sun, 27 Nov 2016 19:32:29 +0000 (+0000) Subject: regress: fuzzraw: Fixes to fdsets X-Git-Tag: adns-1.6.0~55 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=fef04606834147042b18488ddde341bdaf87b602;p=adns.git regress: fuzzraw: Fixes to fdsets Signed-off-by: Ian Jackson --- diff --git a/regress/hfuzzraw.c.m4 b/regress/hfuzzraw.c.m4 index a1a9d0f..faab759 100644 --- a/regress/hfuzzraw.c.m4 +++ b/regress/hfuzzraw.c.m4 @@ -161,23 +161,30 @@ static int Pbytes(byte *buf, int maxlen) { } static void Pfdset(fd_set *set, int max, int *r_io) { - uint16_t got; - int fd, ngot=0; + uint16_t fdmap; + int fd, nfdmap=0; + + if (!set) + return; + + for (fd=max-1; fd>=0; fd--) { + if (nfdmap==0) { + P_READ(fdmap); + nfdmap= 16; + } + _Bool y = fdmap & 1u; + fdmap >>= 1; + nfdmap--; - for (fd=0; fd>= 1; - ngot--; } } diff --git a/regress/hplayback.c.m4 b/regress/hplayback.c.m4 index f6034cb..0c39945 100644 --- a/regress/hplayback.c.m4 +++ b/regress/hplayback.c.m4 @@ -205,6 +205,20 @@ static void Pfdset(fd_set *set, int max) { if (c == hm_squote]hm_squote) break; if (c != hm_squote,hm_squote) Psyntax("fd set separator not ,"); } + + uint16_t accum; + int inaccum=0, fd; + for (fd=0; ; fd++) { + if (fd>=max || inaccum==16) { + FR_WRITE(accum); + inaccum= 0; + } + if (fd>=max) + break; + accum <<= 1; + accum |= !!FD_ISSET(fd,set); + inaccum++; + } } #ifdef HAVE_POLL