public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Érico Nogueira" <ericonr@disroot.org>
To: "Florian Weimer" <fweimer@redhat.com>,
	"Érico Nogueira via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [RFC] linux: use __fd_to_filename helper function instead of snprintf.
Date: Tue, 27 Apr 2021 10:06:57 -0300	[thread overview]
Message-ID: <8c701d36-6b1c-8c5b-2a56-793c2def663f@disroot.org> (raw)
In-Reply-To: <87h7jsp6ma.fsf@oldenburg.str.redhat.com>

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 <fcntl.h>
>>   #include <sys/stat.h>
>>   
>> +#include <fd_to_filename.h>
>>   #include <sysdep.h>
>>   #include <sys/syscall.h>
>>   #include <kernel-features.h>
>> @@ -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
>

      reply	other threads:[~2021-04-27 13:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27  3:09 Érico Nogueira
2021-04-27  6:46 ` Florian Weimer
2021-04-27 13:06   ` Érico Nogueira [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c701d36-6b1c-8c5b-2a56-793c2def663f@disroot.org \
    --to=ericonr@disroot.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).