This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v3] libio: Flush stream at freopen (BZ#21037)
On 02/10/2018 11:46, Andreas Schwab wrote:
> On Okt 01 2018, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
>
>> diff --git a/sysdeps/unix/sysv/linux/fd_to_filename.h b/sysdeps/unix/sysv/linux/fd_to_filename.h
>> index 297716b0ae..62bc9916b0 100644
>> --- a/sysdeps/unix/sysv/linux/fd_to_filename.h
>> +++ b/sysdeps/unix/sysv/linux/fd_to_filename.h
>> @@ -16,30 +16,20 @@
>> License along with the GNU C Library; if not, see
>> <http://www.gnu.org/licenses/>. */
>>
>> -#include <stdlib.h>
>> -#include <string.h>
>> #include <sys/stat.h>
>> -#include <_itoa.h>
>> +
>> +#define FD_TO_FILENAME_SIZE ((sizeof ("/proc/self/fd/") - 1) \
>> + + (sizeof ("4294967295") - 1) + 1)
>>
>> static inline const char *
>> -fd_to_filename (int fd)
>> +fd_to_filename (unsigned int fd, char *buf)
>> {
>> - char *ret = malloc (30);
>> -
>> - if (ret != NULL)
>> - {
>> - struct stat64 st;
>> -
>> - *_fitoa_word (fd, __stpcpy (ret, "/proc/self/fd/"), 10, 0) = '\0';
>> -
>> - /* We must make sure the file exists. */
>> - if (__lxstat64 (_STAT_VER, ret, &st) < 0)
>> - {
>> - /* /proc is not mounted or something else happened. Don't
>> - return the file name. */
>> - free (ret);
>> - ret = NULL;
>> - }
>> - }
>> - return ret;
>> + *_fitoa_word (fd, __stpcpy (buf, "/proc/self/fd/"), 10, 0) = '\0';
>> +
>> + /* We must make sure the file exists. */
>> + struct stat64 st;
>> + if (__lxstat64 (_STAT_VER, buf, &st) < 0)
>> + /* /proc is not mounted or something else happened. */
>> + return NULL;
>> + return buf;
>> }
>
> In file included from freopen.c:33:
> ../sysdeps/unix/sysv/linux/fd_to_filename.h: In function ‘fd_to_filename’:
> ../sysdeps/unix/sysv/linux/fd_to_filename.h:27:4: error: implicit declaration of function ‘_fitoa_word’ [-Werror=implicit-function-declaration]
> *_fitoa_word (fd, __stpcpy (buf, "/proc/self/fd/"), 10, 0) = '\0';
> ^~~~~~~~~~~
> ../sysdeps/unix/sysv/linux/fd_to_filename.h:27:21: error: implicit declaration of function ‘__stpcpy’; did you mean ‘__setpgid’? [-Werror=implicit-function-declaration]
> *_fitoa_word (fd, __stpcpy (buf, "/proc/self/fd/"), 10, 0) = '\0';
> ^~~~~~~~
> __setpgid
> ../sysdeps/unix/sysv/linux/fd_to_filename.h:27:3: error: invalid type argument of unary ‘*’ (have ‘int’)
> *_fitoa_word (fd, __stpcpy (buf, "/proc/self/fd/"), 10, 0) = '\0';
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[2]: *** [../o-iterator.mk:9: /suse/schwab/src/libc/n-riscv64/libio/freopen.o] Error 1
>
> Andreas.
>
I just rerunning a build on multiple abis (as I should have done)
to check it requires mode include fixing.