From bebd154be4d1118b08a23ce3b56a8613c8841cff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Z=C3=A1rev=C3=BAcky?= Date: Tue, 28 May 2019 20:37:57 +0200 Subject: [PATCH] Fix coastline gcc build Not really sure why, but during gcc build the code in is missing the definition of __NAME_MAX from , despite being included. --- abi/include/limits.h | 4 +--- uspace/lib/c/generic/dirent.c | 7 +++++-- uspace/lib/c/include/dirent.h | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/abi/include/limits.h b/abi/include/limits.h index 547d1967b..ecbb3d08a 100644 --- a/abi/include/limits.h +++ b/abi/include/limits.h @@ -83,8 +83,6 @@ _Static_assert(((char)-1) < 0, "char should be signed"); #undef MB_LEN_MAX #define MB_LEN_MAX 4 -#define __NAME_MAX 256 - #ifdef _HELENOS_SOURCE #define UCHAR_MIN 0 #define USHRT_MIN 0 @@ -103,7 +101,7 @@ _Static_assert(((char)-1) < 0, "char should be signed"); defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define SSIZE_MAX INTPTR_MAX -#define NAME_MAX __NAME_MAX +#define NAME_MAX 255 #endif diff --git a/uspace/lib/c/generic/dirent.c b/uspace/lib/c/generic/dirent.c index 17487f540..32101a201 100644 --- a/uspace/lib/c/generic/dirent.c +++ b/uspace/lib/c/generic/dirent.c @@ -38,6 +38,7 @@ #include #include #include +#include struct __dirstream { int fd; @@ -91,13 +92,15 @@ struct dirent *readdir(DIR *dirp) errno_t rc; ssize_t len = 0; - rc = vfs_read_short(dirp->fd, dirp->pos, &dirp->res.d_name[0], - NAME_MAX + 1, &len); + rc = vfs_read_short(dirp->fd, dirp->pos, dirp->res.d_name, + sizeof(dirp->res.d_name), &len); if (rc != EOK) { errno = rc; return NULL; } + assert(strnlen(dirp->res.d_name, sizeof(dirp->res.d_name)) < sizeof(dirp->res.d_name)); + dirp->pos += len; return &dirp->res; diff --git a/uspace/lib/c/include/dirent.h b/uspace/lib/c/include/dirent.h index 181e100cc..5be6eb8b9 100644 --- a/uspace/lib/c/include/dirent.h +++ b/uspace/lib/c/include/dirent.h @@ -35,13 +35,12 @@ #ifndef _LIBC_DIRENT_H_ #define _LIBC_DIRENT_H_ -#include #include <_bits/decls.h> __C_DECLS_BEGIN; struct dirent { - char d_name[__NAME_MAX + 1]; + char d_name[256]; }; typedef struct __dirstream DIR; -- 2.11.4.GIT