This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Initialize pad outside the conditional to prevent uninitialized data warnings.


Notes:

In sem_open.c,  pad was only initialized when __HAVE_64B_ATOMICS was
not true causing valgrind to warn about uninitialized data on some
arches.  This patch moves the initialization of pad outside of the
conditional.

Prior to this change, valgrind warned about unitialized bytes on
ppc64, ppc64le, s390x, and aarch64.

Tested on ppc64le with no regressions.   Used valgrind to confirm that
the uninitialized bytes warning was fixed.
2018-06-22  Patsy Franklin  <pfrankli@redhat.com>

	* nptl/sem_open.c [!__HAVE_64B_ATOMICS] (sem_open): Don't update pad.
	(sem_open): Set sem.newsem.pad to zero for valgrind.

diff --git a/nptl/sem_open.c b/nptl/sem_open.c
index 1d7f142134..c5389f6873 100644
--- a/nptl/sem_open.c
+++ b/nptl/sem_open.c
@@ -215,10 +215,11 @@ sem_open (const char *name, int oflag, ...)
       sem.newsem.data = value;
 #else
       sem.newsem.value = value << SEM_VALUE_SHIFT;
-      /* pad is used as a mutex on pre-v9 sparc and ignored otherwise.  */
-      sem.newsem.pad = 0;
       sem.newsem.nwaiters = 0;
 #endif
+      /* pad is used as a mutex on pre-v9 sparc and ignored otherwise.  */
+      sem.newsem.pad = 0;
+
       /* This always is a shared semaphore.  */
       sem.newsem.private = FUTEX_SHARED;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]