aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2013-04-02 11:38:12 +0000
committerCorinna Vinschen <corinna@vinschen.de>2013-04-02 11:38:12 +0000
commit2e463c77deb8176fe3c160614767b477d605cce4 (patch)
treeffa1af17c7a8cec7a1496acfb0cb525f81ece123
parentbbd4e05a4df4863ce32ba8593024dc9590b9b9dc (diff)
downloadnewlib-2e463c77deb8176fe3c160614767b477d605cce4.zip
newlib-2e463c77deb8176fe3c160614767b477d605cce4.tar.gz
newlib-2e463c77deb8176fe3c160614767b477d605cce4.tar.bz2
* libc/posix/scandir.c (DIRSIZ): Use offsetof instead of magic
number.
-rw-r--r--newlib/ChangeLog5
-rw-r--r--newlib/libc/posix/scandir.c5
2 files changed, 8 insertions, 2 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 2bc96c2..126f5f0 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-02 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * libc/posix/scandir.c (DIRSIZ): Use offsetof instead of magic
+ number.
+
2013-03-27 Bin Cheng <bin.cheng@arm.com>
* acconfig.h (_FVWRITE_IN_STREAMIO): Undefine.
diff --git a/newlib/libc/posix/scandir.c b/newlib/libc/posix/scandir.c
index 96a66de..8cb8ff8 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 <sys/types.h>
#include <sys/stat.h>
+#include <stddef.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
@@ -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