From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1A9963857001 for ; Thu, 8 Jun 2023 06:57:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A9963857001 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686207434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xe53uFl3tWB8IfBH/xCzeMFHNKoWIyLq6BL/Tzo+34U=; b=JzXmj8ZxH09r+9+sjXRaK9GacXdslBh643tnh5xKVo4UrCU+/tUQfT1OHmVlUuvlxdGA4b 0gIXLaJknWaWX1sRDt6sTeODQDmYj3aHCzbmODAPEO8o7n3b8JOdBBdei7GTPtQ9Tc/BbQ 3jvon1Bwq0w5VimgV4C7XFBse24Z9rk= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-_0phZnAxMi2YAz_OWkvEmg-1; Thu, 08 Jun 2023 02:57:13 -0400 X-MC-Unique: _0phZnAxMi2YAz_OWkvEmg-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9715654aba1so43714666b.0 for ; Wed, 07 Jun 2023 23:57:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686207432; x=1688799432; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xe53uFl3tWB8IfBH/xCzeMFHNKoWIyLq6BL/Tzo+34U=; b=d16Pg3od3d9P6XvssE8Vl1gngobIJjwE6hhlrEBFdIQtb7NZA5nckTwtzDvpJgMi7U vecn+QCp+PGjKsNCSk4Rzv0ivft9PnYH+2V34wysu/0FA0kMV25FwBtbqDuEly5ut6N3 zMXNa6TXb19K323miDb+mMf7n3y+d9W5+cR51EQvjf5eO7CC+1qFFp8SzDc/6r4Ru/3f vw4HWaBvcvgeByd0SQGOmp29Zyim85ulLOuh2nxbbiF/Q8kCwFV6MIuYc1LoSyX5T1ON 7ArUu5j18HKXMsS6nlN1/W+A09yXuZ70dkfK4E/Fg5g8DvQ2ZtfTFiEBA3glj7w9UTDV cLPg== X-Gm-Message-State: AC+VfDweYXyHVDSizO7ZUCWYJxzexBCYbTcmVUnbxCeV5KkH60sauxsk mdzVhtZOIkRMq+KFs8jBqUKv1hItW+v3q+NUnquiYKbKdDSGVEezGceIdX4bmWtyhJqx1OHieTT a2INYgk8IYlEhRTeSCvPCXofTjjxOyiveQjQ9rssdCjWl0Jw= X-Received: by 2002:a17:907:7e96:b0:977:d27e:dd5f with SMTP id qb22-20020a1709077e9600b00977d27edd5fmr1283875ejc.28.1686207432428; Wed, 07 Jun 2023 23:57:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BmJQxmdCFT9SnqBTVvE4fDa0/MQbzx+142C5ztf9HiTthu2A+2fFF+SD/ZriVxpgN/QcWoy29MKi3OOvxKKQ= X-Received: by 2002:a17:907:7e96:b0:977:d27e:dd5f with SMTP id qb22-20020a1709077e9600b00977d27edd5fmr1283860ejc.28.1686207432056; Wed, 07 Jun 2023 23:57:12 -0700 (PDT) MIME-Version: 1.0 References: <20230602152812.108497-1-fberat@redhat.com> <20230602152812.108497-6-fberat@redhat.com> In-Reply-To: From: Frederic Berat Date: Thu, 8 Jun 2023 08:57:01 +0200 Message-ID: Subject: Re: [PATCH v6 5/7] tests: replace fgets by xfgets To: Maxim Kuvyrkov Cc: Maxim Kuvyrkov via Libc-alpha , siddhesh@gotplt.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Jun 8, 2023 at 7:51=E2=80=AFAM Maxim Kuvyrkov wrote: > > Hi Fr=C3=A9d=C3=A9ric, > > One of the patches in this series fails lint-makefile test [1]. Let me k= now if you need any assistance in reproducing this. Thanks, yes I noticed that yesterday on patch 2 and 4. Interestingly the patch 3 didn't but I'll fix it too. There is another version pending already, I'll send it soon hopefully. > > =3D=3D=3D > --- /home/maxim.kuvyrkov/tcwg_gnu/glibc/support/Makefile.expected > +++ /home/maxim.kuvyrkov/tcwg_gnu/glibc/support/Makefile 2023-06-0= 8 05:41:24.238665318 +0000 > @@ -126,8 +126,8 @@ > xfgets \ > xfopen \ > xfork \ > - xfread \ > xfreopen \ > + xfread \ > xftruncate \ > xgetline \ > xgetsockname \ > @@ -197,8 +197,8 @@ > xpthread_spin_lock \ > xpthread_spin_unlock \ > xraise \ > - xread \ > xreadlink \ > + xread \ > xrealloc \ > xrecvfrom \ > xsendto \ > @@ -211,8 +211,8 @@ > xstrdup \ > xstrndup \ > xsymlink \ > - xsysconf \ > xsystem \ > + xsysconf \ > xunlink \ > xuselocale \ > xwaitpid \ > --- > Tested 200 Makefiles and 1 were incorrectly sorted > Please use `patch -R -pN` and the output above to correct the sorting > =3D=3D=3D > > [1] https://ci.linaro.org/job/tcwg_glibc_check--master-aarch64-build/321/= artifact/artifacts/artifacts.precommit/07-check_regression/fails.sum/*view*= / > > -- > Maxim Kuvyrkov > https://www.linaro.org > > > > > > On Jun 2, 2023, at 19:28, Fr=C3=A9d=C3=A9ric B=C3=A9rat via Libc-alpha = wrote: > > > > With fortification enabled, fgets calls return result needs to be check= ed, > > has it gets the __wur macro enabled. > > --- > > Changes since v4/v5: > > - Rebased > > > > assert/test-assert-perr.c | 8 +++++--- > > assert/test-assert.c | 8 +++++--- > > stdio-common/test_rdwr.c | 11 ++++------- > > support/Makefile | 1 + > > support/xfgets.c | 32 ++++++++++++++++++++++++++++++++ > > support/xstdio.h | 1 + > > sysdeps/pthread/tst-cancel6.c | 3 ++- > > 7 files changed, 50 insertions(+), 14 deletions(-) > > create mode 100644 support/xfgets.c > > > > diff --git a/assert/test-assert-perr.c b/assert/test-assert-perr.c > > index 8496db6ffd..09a4fcb6ef 100644 > > --- a/assert/test-assert-perr.c > > +++ b/assert/test-assert-perr.c > > @@ -11,6 +11,8 @@ > > #include > > #include > > > > +#include > > + > > jmp_buf rec; > > char buf[160]; > > > > @@ -70,15 +72,15 @@ main(void) > > failed =3D 1; /* should not happen */ > > > > rewind (stderr); > > - fgets (buf, 160, stderr); > > + xfgets (buf, 160, stderr); > > if (!strstr(buf, strerror (1))) > > failed =3D 1; > > > > - fgets (buf, 160, stderr); > > + xfgets (buf, 160, stderr); > > if (strstr (buf, strerror (0))) > > failed =3D 1; > > > > - fgets (buf, 160, stderr); > > + xfgets (buf, 160, stderr); > > if (strstr (buf, strerror (2))) > > failed =3D 1; > > > > diff --git a/assert/test-assert.c b/assert/test-assert.c > > index 26b58d4dd3..25e264543b 100644 > > --- a/assert/test-assert.c > > +++ b/assert/test-assert.c > > @@ -11,6 +11,8 @@ > > #include > > #include > > > > +#include > > + > > jmp_buf rec; > > char buf[160]; > > > > @@ -72,15 +74,15 @@ main (void) > > failed =3D 1; /* should not happen */ > > > > rewind (stderr); > > - fgets (buf, 160, stderr); > > + xfgets (buf, 160, stderr); > > if (!strstr (buf, "1 =3D=3D 2")) > > failed =3D 1; > > > > - fgets (buf, 160, stderr); > > + xfgets (buf, 160, stderr); > > if (strstr (buf, "1 =3D=3D 1")) > > failed =3D 1; > > > > - fgets (buf, 160, stderr); > > + xfgets (buf, 160, stderr); > > if (strstr (buf, "2 =3D=3D 3")) > > failed =3D 1; > > > > diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c > > index 7825ca9358..0544916eb1 100644 > > --- a/stdio-common/test_rdwr.c > > +++ b/stdio-common/test_rdwr.c > > @@ -20,6 +20,7 @@ > > #include > > #include > > > > +#include > > > > int > > main (int argc, char **argv) > > @@ -49,7 +50,7 @@ main (int argc, char **argv) > > > > (void) fputs (hello, f); > > rewind (f); > > - (void) fgets (buf, sizeof (buf), f); > > + xfgets (buf, sizeof (buf), f); > > rewind (f); > > (void) fputs (buf, f); > > rewind (f); > > @@ -104,12 +105,8 @@ main (int argc, char **argv) > > if (!lose) > > { > > rewind (f); > > - if (fgets (buf, sizeof (buf), f) =3D=3D NULL) > > - { > > - printf ("fgets got %s.\n", strerror(errno)); > > - lose =3D 1; > > - } > > - else if (strcmp (buf, replace)) > > + xfgets (buf, sizeof (buf), f); > > + if (strcmp (buf, replace)) > > { > > printf ("Read \"%s\" instead of \"%s\".\n", buf, replace); > > lose =3D 1; > > diff --git a/support/Makefile b/support/Makefile > > index 3eed2deb1a..bbd3465d04 100644 > > --- a/support/Makefile > > +++ b/support/Makefile > > @@ -123,6 +123,7 @@ libsupport-routines =3D \ > > xdup2 \ > > xfchmod \ > > xfclose \ > > + xfgets \ > > xfopen \ > > xfork \ > > xfreopen \ > > diff --git a/support/xfgets.c b/support/xfgets.c > > new file mode 100644 > > index 0000000000..e2db19cf53 > > --- /dev/null > > +++ b/support/xfgets.c > > @@ -0,0 +1,32 @@ > > +/* fgets with error checking. > > + Copyright (C) 2016-2023 Free Software Foundation, Inc. > > + This file is part of the GNU C Library. > > + > > + The GNU C Library is free software; you can redistribute it and/or > > + modify it under the terms of the GNU Lesser General Public > > + License as published by the Free Software Foundation; either > > + version 2.1 of the License, or (at your option) any later version. > > + > > + The GNU C Library is distributed in the hope that it will be useful= , > > + but WITHOUT ANY WARRANTY; without even the implied warranty of > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + Lesser General Public License for more details. > > + > > + You should have received a copy of the GNU Lesser General Public > > + License along with the GNU C Library; if not, see > > + . */ > > + > > +#include > > + > > +#include > > +#include > > + > > +char * > > +xfgets (char *s, int size, FILE *stream) > > +{ > > + char *ret =3D fgets (s, size, stream); > > + if (!ret && ferror(stream)) > > + FAIL_EXIT1 ("fgets failed: %m"); > > + > > + return ret; > > +} > > diff --git a/support/xstdio.h b/support/xstdio.h > > index 633c342c82..f30bee6a20 100644 > > --- a/support/xstdio.h > > +++ b/support/xstdio.h > > @@ -28,6 +28,7 @@ FILE *xfopen (const char *path, const char *mode); > > void xfclose (FILE *); > > FILE *xfreopen (const char *path, const char *mode, FILE *stream); > > void xfread (void *ptr, size_t size, size_t nmemb, FILE *stream); > > +char *xfgets (char *s, int size, FILE *stream); > > > > /* Read a line from FP, using getline. *BUFFER must be NULL, or a > > heap-allocated pointer of *LENGTH bytes. Return the number of > > diff --git a/sysdeps/pthread/tst-cancel6.c b/sysdeps/pthread/tst-cancel= 6.c > > index 63e6d49707..49b7399353 100644 > > --- a/sysdeps/pthread/tst-cancel6.c > > +++ b/sysdeps/pthread/tst-cancel6.c > > @@ -20,12 +20,13 @@ > > #include > > #include > > > > +#include > > > > static void * > > tf (void *arg) > > { > > char buf[100]; > > - fgets (buf, sizeof (buf), arg); > > + xfgets (buf, sizeof (buf), arg); > > /* This call should never return. */ > > return NULL; > > } > > -- > > 2.40.1 > > >