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.133.124]) by sourceware.org (Postfix) with ESMTPS id 8CB0F3858D35 for ; Mon, 22 May 2023 12:36:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8CB0F3858D35 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=1684759016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=75JgP4lMQYb6Da+3psPylDjpzqPC2d+/QFKD6jXCq7w=; b=PdsSgfr6IbIsurSPhOLGb/C80UKCfOCmqm/OXgUrEI41bpsfITDXVXQEHrejkL4qlaYuBc oT0qnoX6qxJoshSWtlUXhwBNGDz8tdV+R/FX32LPeKNxCEyUv3bQKA/9AUKhuXUygjIbhZ xRQJm3QYR97XWrLt3T/hP0QaBEvylL8= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-288-PkWuyF5ZOxiGL43xYN7QZw-1; Mon, 22 May 2023 08:36:55 -0400 X-MC-Unique: PkWuyF5ZOxiGL43xYN7QZw-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-560def4d06dso113072887b3.3 for ; Mon, 22 May 2023 05:36:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684759014; x=1687351014; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=75JgP4lMQYb6Da+3psPylDjpzqPC2d+/QFKD6jXCq7w=; b=Yt9sImo5neRSahJqBgPkIvH58Z99+KdHz3ek3Go90LfuGpt7djTnBdpJUa/CWBxhHr gNR5ncJVLiyQ3+j3HliIGd7P8sdrANNq7GtKa1nbZmaIuAlN5h4iZOrgaq948GkXN0AQ 8s1Rl/C2TJq7xflc8awrZlUVKzjjHJ4BbvyvP1OU3CWs3QNbq0hb9prIghdKGhDS5miS BxEEWhYskG7LBHRTrMXRAfA/+4PZA9RBaSR+ZjuWQDZTZJV8RNKCDdW9kTx4MHRwbIwn BoSCOV60V7ys0X5Lw/K0BvAVR4g5sP4aAC2Lse+7FHXE16FHHKwCgb4jKldHoKcmU7d6 H4Dg== X-Gm-Message-State: AC+VfDyN5POR9KxA7VBdRiRqHooMg/qJ25TW+lzOZKBh/1iyQyX6HvEF qQWtd0x9z/jkgawZKjFIJaCSQzHHuvCmAqeUKU09nXNkuSjOTaxnXagRqaZCgdfvkccFWRAsX+I 2hf+b7xIXGz+9v2HBLhoIHUrIRUp/ X-Received: by 2002:a81:7cc3:0:b0:565:f3c:6a0d with SMTP id x186-20020a817cc3000000b005650f3c6a0dmr615424ywc.29.1684759014385; Mon, 22 May 2023 05:36:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4tDVtZPsK/vNtCTUAlU6Mbi+5yRFU04gfRM779nQ8OgYfkdXGUYSc3zANlqRXNYkGyXynksQ== X-Received: by 2002:a81:7cc3:0:b0:565:f3c:6a0d with SMTP id x186-20020a817cc3000000b005650f3c6a0dmr615418ywc.29.1684759014109; Mon, 22 May 2023 05:36:54 -0700 (PDT) Received: from [192.168.0.241] ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id r129-20020a818187000000b0055a85ab2704sm2023767ywf.20.2023.05.22.05.36.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 May 2023 05:36:53 -0700 (PDT) Message-ID: <8bd8f5a0-b94a-9199-61e8-06fc5b87d79e@redhat.com> Date: Mon, 22 May 2023 08:36:52 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: Ping: [PATCH] libio: Add __nonnull for FILE * arguments of fclose and freopen To: Adhemerval Zanella Netto , Xi Ruoyao , libc-alpha@sourceware.org References: <20230421062133.2084910-1-xry111@xry111.site> <08675b0b0b196802c08fc684c15c6a4bc09c7668.camel@xry111.site> From: Carlos O'Donell Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 5/16/23 06:04, Adhemerval Zanella Netto wrote: > Done. Thanks for pushing this last week! > On 15/05/23 23:50, Xi Ruoyao wrote: >> Ping, as this seems reviewed as OK but fallen through two review >> meetings. >> >> On Fri, 2023-04-21 at 14:21 +0800, Xi Ruoyao wrote: >>> Calling fclose or freopen with a null FILE * is undefined behavior, >>> and >>> doing so in practice will cause a SIGSEGV.  So it seems suitable for >>> __nonnull. >>> >>> This will help the compiler to warn for some buggy code, like >>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109570. >>> --- >>>  libio/stdio.h | 6 +++--- >>>  1 file changed, 3 insertions(+), 3 deletions(-) >>> >>> diff --git a/libio/stdio.h b/libio/stdio.h >>> index 45ddafdf20..bfb8415d3b 100644 >>> --- a/libio/stdio.h >>> +++ b/libio/stdio.h >>> @@ -180,7 +180,7 @@ extern int renameat2 (int __oldfd, const char >>> *__old, int __newfd, >>>   >>>     This function is a possible cancellation point and therefore not >>>     marked with __THROW.  */ >>> -extern int fclose (FILE *__stream); >>> +extern int fclose (FILE *__stream) __nonnull ((1)); >>>   >>>  #undef __attr_dealloc_fclose >>>  #define __attr_dealloc_fclose __attr_dealloc (fclose, 1) >>> @@ -269,7 +269,7 @@ extern FILE *fopen (const char *__restrict >>> __filename, >>>     marked with __THROW.  */ >>>  extern FILE *freopen (const char *__restrict __filename, >>>                       const char *__restrict __modes, >>> -                     FILE *__restrict __stream) __wur; >>> +                     FILE *__restrict __stream) __wur __nonnull >>> ((3)); >>>  #else >>>  # ifdef __REDIRECT >>>  extern FILE *__REDIRECT (fopen, (const char *__restrict __filename, >>> @@ -290,7 +290,7 @@ extern FILE *fopen64 (const char *__restrict >>> __filename, >>>    __attribute_malloc__ __attr_dealloc_fclose __wur; >>>  extern FILE *freopen64 (const char *__restrict __filename, >>>                         const char *__restrict __modes, >>> -                       FILE *__restrict __stream) __wur; >>> +                       FILE *__restrict __stream) __wur __nonnull >>> ((3)); >>>  #endif >>>   >>>  #ifdef __USE_POSIX >> > -- Cheers, Carlos.