From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 2119A3858439 for ; Tue, 16 May 2023 10:04:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2119A3858439 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6ab38a85a1eso5054023a34.1 for ; Tue, 16 May 2023 03:04:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684231484; x=1686823484; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=4ejd/vYAZyUEmCR8ujRJXDj2uoLJRy5T0qGmOSu90xw=; b=pd7YlXPWqoLXg4FGSxtVBE7Wn/ln+PSnKzPBz7Q4kyEBXVHhegw2vGt+zFIJUdNJ2l S1yz/EVcsQcIdoIxVCm54pXMcNzS0Qt24VkvLiprc4aKz5LW01kpQy4WQwJg826WMbCt Rt05G2BtL1UmthIlCDm6puRBUTw7xZYIMV8iPWliBKeJPXGgJAPMZWbzX50QzsWuUTlI Rv1YtHDPaIL/DBeBOoRwZzopYBg+bcAaT9fX+QgCbRiN6ZzC8XtoTRxUJqP9wzxDq19g vQiaduIvcZACBIfxq9nmT9uRV6mE/MIMLoZYngOnBqZFIphE95N4e/qTom84iN1vQOdw tx+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684231484; x=1686823484; h=content-transfer-encoding:in-reply-to:organization:from:references :cc: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=4ejd/vYAZyUEmCR8ujRJXDj2uoLJRy5T0qGmOSu90xw=; b=jtFKbtNQs6qwgiIq1oHMSaFbr9dY3jbOucC+jq/CGvvR27IeNDgcBrwwaGrr2xXP9h uC/xaLQQ60Hg2j3mpk6dbETeS/nVQs2tTd1sRyGYAxTasPou+0A6/RJzYA0cwiYLzi1S lnGjs5yNImFdt2nWHVP+5PrLnih8+qSGw7HjFxrJeXrEWCA5s9paV1BqzDwyd67aven8 t7SgHHemvxjs24V3xWevDv9ngd+CYZ4fQDdShnDfSJHRqX9P/Digsh0PUlN2lo3f+R2s JDVvXl5uTw+YCi81yCUN7UD/rXZLG5SIepnzi9G+trDnxzeFAJnGe9yo2GDXUZAX9swX nZDg== X-Gm-Message-State: AC+VfDzSHupNI+hmSLPmqZECWExqi0lRZxQsw++/a4BXd8743KtJxfwp N1yZQga1DZ8QB7ghe/b7OAIVdA== X-Google-Smtp-Source: ACHHUZ6JIlhqrbVthezQm6Y1p1O0GTQlxBDrGNi0y5i/XSx1XhjZADYoh4TJXh+mje6XrIGunhSpZw== X-Received: by 2002:a9d:7dcb:0:b0:6ab:0:78ed with SMTP id k11-20020a9d7dcb000000b006ab000078edmr11706043otn.2.1684231484382; Tue, 16 May 2023 03:04:44 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:c914:28b3:cbf9:a103:6f88? ([2804:1b3:a7c0:c914:28b3:cbf9:a103:6f88]) by smtp.gmail.com with ESMTPSA id t12-20020a9d774c000000b006ab1ea1af9esm7255968otl.68.2023.05.16.03.04.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 May 2023 03:04:43 -0700 (PDT) Message-ID: Date: Tue, 16 May 2023 07:04:40 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: Ping: [PATCH] libio: Add __nonnull for FILE * arguments of fclose and freopen Content-Language: en-US To: Xi Ruoyao , libc-alpha@sourceware.org Cc: Carlos O'Donell References: <20230421062133.2084910-1-xry111@xry111.site> <08675b0b0b196802c08fc684c15c6a4bc09c7668.camel@xry111.site> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <08675b0b0b196802c08fc684c15c6a4bc09c7668.camel@xry111.site> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: Done. 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 >