From patchwork Wed Jul 5 14:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1803735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Y+LqmABx; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx1rw4zRhz20Pf for ; Thu, 6 Jul 2023 00:15:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A84EB3865C27 for ; Wed, 5 Jul 2023 14:15:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A84EB3865C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688566510; bh=cfZpW+5KQq5TkdvBMXXwSUWcpd+t+10deNj/BF5SbE4=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Y+LqmABxgXe+MrViu3JA/4wKtwC+s05j3keXOuCeYaGbTfYoXJ1XSXpj4CRUwPep2 eJVJ3kpiwcLgyoURHAWfzh3vM2qHk8Ue9y64/PRqLDlYRam1xE+QgIyMhiojxAks5V nvsSjYTkjMrZtpMcdfGQfhQ1s51X0BcXd9ViHMgQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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 026A13857737 for ; Wed, 5 Jul 2023 14:11:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 026A13857737 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-GiI3jJm5NoWHvqoaKzgRFQ-1; Wed, 05 Jul 2023 10:11:19 -0400 X-MC-Unique: GiI3jJm5NoWHvqoaKzgRFQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 484BB8688DF; Wed, 5 Jul 2023 14:11:19 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.42.28.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 53DD7F6403; Wed, 5 Jul 2023 14:11:18 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com, Siddhesh Poyarekar Subject: [PATCH v5 12/14] libio/bits/stdio2.h: Clearly separate declaration from definitions Date: Wed, 5 Jul 2023 16:10:47 +0200 Message-ID: <20230705141055.274575-13-fberat@redhat.com> In-Reply-To: <20230705141055.274575-1-fberat@redhat.com> References: <20230705141055.274575-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Move declarations from libio/bits/stdio.h to existing libio/bits/stdio2-decl.h. This will enable future use of __REDIRECT_FORTIFY in place of some __REDIRECT. Reviewed-by: Siddhesh Poyarekar --- libio/bits/stdio2-decl.h | 49 ++++++++++++++++++++++++++++++++++++++++ libio/bits/stdio2.h | 48 --------------------------------------- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/libio/bits/stdio2-decl.h b/libio/bits/stdio2-decl.h index 9d4668da21..114b06d24b 100644 --- a/libio/bits/stdio2-decl.h +++ b/libio/bits/stdio2-decl.h @@ -84,18 +84,55 @@ extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack, #endif #if __GLIBC_USE (DEPRECATED_GETS) +extern char *__REDIRECT (__gets_warn, (char *__str), gets) + __wur __warnattr ("please use fgets or getline instead, gets can't " + "specify buffer size"); + extern char *__gets_chk (char *__str, size_t) __wur; #endif +extern char *__REDIRECT (__fgets_alias, + (char *__restrict __s, int __n, + FILE *__restrict __stream), fgets) + __wur __attr_access ((__write_only__, 1, 2)); +extern char *__REDIRECT (__fgets_chk_warn, + (char *__restrict __s, size_t __size, int __n, + FILE *__restrict __stream), __fgets_chk) + __wur __warnattr ("fgets called with bigger size than length " + "of destination buffer"); + extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __wur __attr_access ((__write_only__, 1, 3)); +extern size_t __REDIRECT (__fread_alias, + (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream), + fread) __wur; +extern size_t __REDIRECT (__fread_chk_warn, + (void *__restrict __ptr, size_t __ptrlen, + size_t __size, size_t __n, + FILE *__restrict __stream), + __fread_chk) + __wur __warnattr ("fread called with bigger size * nmemb than length " + "of destination buffer"); + extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __wur; #ifdef __USE_GNU +extern char *__REDIRECT (__fgets_unlocked_alias, + (char *__restrict __s, int __n, + FILE *__restrict __stream), fgets_unlocked) + __wur __attr_access ((__write_only__, 1, 2)); +extern char *__REDIRECT (__fgets_unlocked_chk_warn, + (char *__restrict __s, size_t __size, int __n, + FILE *__restrict __stream), __fgets_unlocked_chk) + __wur __warnattr ("fgets_unlocked called with bigger size than length " + "of destination buffer"); + + extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __wur __attr_access ((__write_only__, 1, 3)); @@ -103,6 +140,18 @@ extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size, #ifdef __USE_MISC # undef fread_unlocked +extern size_t __REDIRECT (__fread_unlocked_alias, + (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream), + fread_unlocked) __wur; +extern size_t __REDIRECT (__fread_unlocked_chk_warn, + (void *__restrict __ptr, size_t __ptrlen, + size_t __size, size_t __n, + FILE *__restrict __stream), + __fread_unlocked_chk) + __wur __warnattr ("fread_unlocked called with bigger size * nmemb than " + "length of destination buffer"); + extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __wur; diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h index ad85f7df8b..71226408ab 100644 --- a/libio/bits/stdio2.h +++ b/libio/bits/stdio2.h @@ -182,10 +182,6 @@ __NTH (obstack_vprintf (struct obstack *__restrict __obstack, #endif #if __GLIBC_USE (DEPRECATED_GETS) -extern char *__REDIRECT (__gets_warn, (char *__str), gets) - __wur __warnattr ("please use fgets or getline instead, gets can't " - "specify buffer size"); - __fortify_function __wur char * gets (char *__str) { @@ -195,16 +191,6 @@ gets (char *__str) } #endif -extern char *__REDIRECT (__fgets_alias, - (char *__restrict __s, int __n, - FILE *__restrict __stream), fgets) - __wur __attr_access ((__write_only__, 1, 2)); -extern char *__REDIRECT (__fgets_chk_warn, - (char *__restrict __s, size_t __size, int __n, - FILE *__restrict __stream), __fgets_chk) - __wur __warnattr ("fgets called with bigger size than length " - "of destination buffer"); - __fortify_function __wur __fortified_attr_access (__write_only__, 1, 2) char * fgets (char *__restrict __s, int __n, FILE *__restrict __stream) { @@ -216,18 +202,6 @@ fgets (char *__restrict __s, int __n, FILE *__restrict __stream) return __fgets_chk (__s, sz, __n, __stream); } -extern size_t __REDIRECT (__fread_alias, - (void *__restrict __ptr, size_t __size, - size_t __n, FILE *__restrict __stream), - fread) __wur; -extern size_t __REDIRECT (__fread_chk_warn, - (void *__restrict __ptr, size_t __ptrlen, - size_t __size, size_t __n, - FILE *__restrict __stream), - __fread_chk) - __wur __warnattr ("fread called with bigger size * nmemb than length " - "of destination buffer"); - __fortify_function __wur size_t fread (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) @@ -241,16 +215,6 @@ fread (void *__restrict __ptr, size_t __size, size_t __n, } #ifdef __USE_GNU -extern char *__REDIRECT (__fgets_unlocked_alias, - (char *__restrict __s, int __n, - FILE *__restrict __stream), fgets_unlocked) - __wur __attr_access ((__write_only__, 1, 2)); -extern char *__REDIRECT (__fgets_unlocked_chk_warn, - (char *__restrict __s, size_t __size, int __n, - FILE *__restrict __stream), __fgets_unlocked_chk) - __wur __warnattr ("fgets_unlocked called with bigger size than length " - "of destination buffer"); - __fortify_function __wur __fortified_attr_access (__write_only__, 1, 2) char * fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) { @@ -265,18 +229,6 @@ fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) #ifdef __USE_MISC # undef fread_unlocked -extern size_t __REDIRECT (__fread_unlocked_alias, - (void *__restrict __ptr, size_t __size, - size_t __n, FILE *__restrict __stream), - fread_unlocked) __wur; -extern size_t __REDIRECT (__fread_unlocked_chk_warn, - (void *__restrict __ptr, size_t __ptrlen, - size_t __size, size_t __n, - FILE *__restrict __stream), - __fread_unlocked_chk) - __wur __warnattr ("fread_unlocked called with bigger size * nmemb than " - "length of destination buffer"); - __fortify_function __wur size_t fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream)