From 2e463c77deb8176fe3c160614767b477d605cce4 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 2 Apr 2013 11:38:12 +0000 Subject: * libc/posix/scandir.c (DIRSIZ): Use offsetof instead of magic number. --- newlib/libc/posix/scandir.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'newlib/libc/posix') diff --git a/newlib/libc/posix/scandir.c b/newlib/libc/posix/scandir.c index 96a66deb9..8cb8ff82d 100644 --- a/newlib/libc/posix/scandir.c +++ b/newlib/libc/posix/scandir.c @@ -42,6 +42,7 @@ static char sccsid[] = "@(#)scandir.c 5.10 (Berkeley) 2/23/91"; #include #include +#include #include #include #include @@ -56,10 +57,10 @@ static char sccsid[] = "@(#)scandir.c 5.10 (Berkeley) 2/23/91"; #undef DIRSIZ #ifdef _DIRENT_HAVE_D_NAMLEN #define DIRSIZ(dp) \ - ((sizeof (struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) + (offsetof (struct dirent, d_name) + (((dp)->d_namlen+1 + 3) &~ 3)) #else #define DIRSIZ(dp) \ - ((sizeof (struct dirent) - (MAXNAMLEN+1)) + ((strlen((dp)->d_name)+1 + 3) &~ 3)) + (offsetof (struct dirent, d_name) + ((strlen((dp)->d_name)+1 + 3) &~ 3)) #endif #ifndef __P -- cgit v1.2.3