From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18666 invoked by alias); 1 May 2013 02:44:06 -0000 Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org Received: (qmail 18648 invoked by uid 89); 1 May 2013 02:44:05 -0000 X-Spam-SWARE-Status: No, score=-7.2 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS,TW_FD autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 01 May 2013 02:44:05 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r412i3r9007412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Apr 2013 22:44:03 -0400 Received: from [10.3.113.84] (ovpn-113-84.phx2.redhat.com [10.3.113.84]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r412i2gK026258; Tue, 30 Apr 2013 22:44:02 -0400 Message-ID: <51808172.8060509@redhat.com> Date: Wed, 01 May 2013 02:44:00 -0000 From: "Carlos O'Donell" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 MIME-Version: 1.0 To: KOSAKI Motohiro CC: libc-alpha@sourceware.org, libc-ports@sourceware.org Subject: Re: [PATCH 4/5] tst-chk1: add fd_set dynamic allocation test References: <1365900451-19026-1-git-send-email-kosaki.motohiro@gmail.com> <1365900451-19026-5-git-send-email-kosaki.motohiro@gmail.com> In-Reply-To: <1365900451-19026-5-git-send-email-kosaki.motohiro@gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-05/txt/msg00002.txt.bz2 On 04/13/2013 08:47 PM, KOSAKI Motohiro wrote: > Signed-off-by: KOSAKI Motohiro > --- > ChangeLog | 5 ++++ > debug/tst-chk1.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 67 insertions(+), 1 deletions(-) > > diff --git a/ChangeLog b/ChangeLog > index 7cdece7..b154c3c 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -29,6 +29,11 @@ > > 2013-03-25 KOSAKI Motohiro > > + * debug/tst-chk1.c (do_test): Added tests for fd_set allocation > + from heap. > + > +2013-03-25 KOSAKI Motohiro > + > * debug/fdelt_chk.c (__fdelt_chk): Removed range check > and renamed to __fdelt_nochk. > > diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c > index 6ca8d9d..2b225ad 100644 > --- a/debug/tst-chk1.c > +++ b/debug/tst-chk1.c > @@ -32,7 +32,7 @@ > #include > #include > #include > - > +#include > > #define obstack_chunk_alloc malloc > #define obstack_chunk_free free > @@ -1451,24 +1451,85 @@ do_test (void) > #endif > > fd_set s; > + fd_set *pfdset; > FD_ZERO (&s); > FD_SET (FD_SETSIZE - 1, &s); > #if __USE_FORTIFY_LEVEL >= 1 > CHK_FAIL_START > FD_SET (FD_SETSIZE, &s); > CHK_FAIL_END Please add comments explaining *why* we are testing this usage pattern e.g. Linux and BSDs support fds > FD_SETSIZE. > + > + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask)); > + if (pfdset == NULL) { > + printf("malloc failed %m\n"); > + return 1; > + } > + FD_SET (FD_SETSIZE, pfdset); > + free (pfdset); > + > + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE*2, NFDBITS), sizeof(fd_mask)); > + if (pfdset == NULL) { > + printf("malloc failed %m\n"); > + return 1; > + } > + CHK_FAIL_START > + FD_SET (FD_SETSIZE*2, pfdset); > + CHK_FAIL_END > + free (pfdset); > #endif > FD_CLR (FD_SETSIZE - 1, &s); > #if __USE_FORTIFY_LEVEL >= 1 > CHK_FAIL_START > FD_CLR (FD_SETSIZE, &s); > CHK_FAIL_END > + > + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask)); > + if (pfdset == NULL) { > + printf("malloc failed %m\n"); > + return 1; > + } > + FD_CLR (FD_SETSIZE, pfdset); > + > + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE*2, NFDBITS), sizeof(fd_mask)); > + if (pfdset == NULL) { > + printf("malloc failed %m\n"); > + return 1; > + } > + free (pfdset); > + > + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE*2, NFDBITS), sizeof(fd_mask)); > + if (pfdset == NULL) { > + printf("malloc failed %m\n"); > + return 1; > + } > + CHK_FAIL_START > + FD_CLR (FD_SETSIZE*2, pfdset); > + CHK_FAIL_END > + free (pfdset); > #endif > FD_ISSET (FD_SETSIZE - 1, &s); > #if __USE_FORTIFY_LEVEL >= 1 > CHK_FAIL_START > FD_ISSET (FD_SETSIZE, &s); > CHK_FAIL_END > + > + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE+1, NFDBITS), sizeof(fd_mask)); > + if (pfdset == NULL) { > + printf("malloc failed %m\n"); > + return 1; > + } > + FD_ISSET (FD_SETSIZE, pfdset); > + free (pfdset); > + > + pfdset = (fd_set*)calloc(howmany(FD_SETSIZE*2, NFDBITS), sizeof(fd_mask)); > + if (pfdset == NULL) { > + printf("malloc failed %m\n"); > + return 1; > + } > + CHK_FAIL_START > + FD_ISSET (FD_SETSIZE*2, pfdset); > + CHK_FAIL_END > + free (pfdset); > #endif > > struct pollfd fds[1]; >