Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Use __builtin_offsetof if present for _DIRENT_NAMEOF...



details:   https://anonhg.NetBSD.org/src/rev/106d21237087
branches:  trunk
changeset: 765273:106d21237087
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon May 23 21:59:23 2011 +0000

description:
Use __builtin_offsetof if present for _DIRENT_NAMEOFF to avoid false
positives for uninitialized variable checks.

diffstat:

 sys/sys/dirent.h |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (22 lines):

diff -r 4bb740c22265 -r 106d21237087 sys/sys/dirent.h
--- a/sys/sys/dirent.h  Mon May 23 21:52:54 2011 +0000
+++ b/sys/sys/dirent.h  Mon May 23 21:59:23 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dirent.h,v 1.24 2008/03/15 19:02:49 christos Exp $     */
+/*     $NetBSD: dirent.h,v 1.25 2011/05/23 21:59:23 joerg Exp $        */
 
 /*-
  * Copyright (c) 1989, 1993
@@ -83,8 +83,12 @@
  * The _DIRENT_NAMEOFF macro returns the offset of the d_name field in 
  * struct dirent
  */
+#if __GNUC_PREREQ__(4, 0)
+#define        _DIRENT_NAMEOFF(dp)     __builtin_offsetof(struct dirent, d_name)
+#else
 #define _DIRENT_NAMEOFF(dp) \
     ((char *)(void *)&(dp)->d_name - (char *)(void *)dp)
+#endif
 /*
  * The _DIRENT_RECLEN macro gives the minimum record length which will hold
  * a name of size "namlen".  This requires the amount of space in struct dirent



Home | Main Index | Thread Index | Old Index