From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by sourceware.org (Postfix) with ESMTPS id 1EC8539888BC for ; Tue, 27 Apr 2021 13:07:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1EC8539888BC Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 7F56653014; Tue, 27 Apr 2021 15:07:09 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zcHXaOjKOQId; Tue, 27 Apr 2021 15:07:07 +0200 (CEST) Subject: Re: [RFC] linux: use __fd_to_filename helper function instead of snprintf. To: Florian Weimer , =?UTF-8?Q?=c3=89rico_Nogueira_via_Libc-alpha?= References: <20210427030937.10380-1-ericonr@disroot.org> <87h7jsp6ma.fsf@oldenburg.str.redhat.com> From: =?UTF-8?Q?=c3=89rico_Nogueira?= Message-ID: <8c701d36-6b1c-8c5b-2a56-793c2def663f@disroot.org> Date: Tue, 27 Apr 2021 10:06:57 -0300 Mime-Version: 1.0 In-Reply-To: <87h7jsp6ma.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Tue, 27 Apr 2021 13:07:13 -0000 Em 27/04/2021 03:46, Florian Weimer escreveu: > * Érico Nogueira via Libc-alpha: > >> diff --git a/sysdeps/unix/sysv/linux/fexecve.c b/sysdeps/unix/sysv/linux/fexecve.c >> index f37c245396..218337a3b5 100644 >> --- a/sysdeps/unix/sysv/linux/fexecve.c >> +++ b/sysdeps/unix/sysv/linux/fexecve.c >> @@ -22,6 +22,7 @@ >> #include >> #include >> >> +#include >> #include >> #include >> #include >> @@ -50,8 +51,8 @@ fexecve (int fd, char *const argv[], char *const envp[]) >> #ifndef __ASSUME_EXECVEAT >> /* We use the /proc filesystem to get the information. If it is not >> mounted we fail. */ >> - char buf[sizeof "/proc/self/fd/" + sizeof (int) * 3]; >> - __snprintf (buf, sizeof (buf), "/proc/self/fd/%d", fd); >> + struct fd_to_filename filename; >> + char *buf = fd_to_filename(fd, &filename); > > Sorry, this patch fails to build if applied to current master: I hadn't commited the fix from my work tree, sorry. > > ../sysdeps/unix/sysv/linux/fexecve.c: In function ‘fexecve’: > ../sysdeps/unix/sysv/linux/fexecve.c:55:15: error: implicit declaration of function ‘fd_to_filename’ [-Werror=implicit-function-declaration] > 55 | char *buf = fd_to_filename(fd, &filename); > | ^~~~~~~~~~~~~~ > > Please also add a space before the opening '(', to match GNU style, and > consider if the code becomes clearer if you avoid the buf variable. I think it's basically as clear as, but a bit more compact, so I will use that instead. Thanks! > > Thanks, > Florian >