Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Revert previous change because it causes uninitializ...



details:   https://anonhg.NetBSD.org/src/rev/784627497902
branches:  trunk
changeset: 989131:784627497902
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Oct 12 17:06:26 2021 +0000

description:
Revert previous change because it causes uninitialized warnings with KMSAN.
The previous code was correct. Add a comment explaining why. Requested by chuq@

diffstat:

 sys/sys/socket.h |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (25 lines):

diff -r c7387340ea93 -r 784627497902 sys/sys/socket.h
--- a/sys/sys/socket.h  Tue Oct 12 15:55:31 2021 +0000
+++ b/sys/sys/socket.h  Tue Oct 12 17:06:26 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: socket.h,v 1.129 2018/11/04 16:30:29 christos Exp $    */
+/*     $NetBSD: socket.h,v 1.130 2021/10/12 17:06:26 christos Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -392,10 +392,13 @@
 
 /*
  * Compute size of a sockcred structure with groups.
+ *
+ * The (ngrps - 1) is to account for struct sockcred being defined with
+ * already one group member. This code works correctly when ngroups == 0
+ * because of unsigned arithmetic wrap-around.
  */
 #define        SOCKCREDSIZE(ngrps) \
-       (/*CONSTCOND*/sizeof(struct sockcred) + (sizeof(gid_t) * \
-           ((ngrps) ? ((ngrps) - 1) : 0)))
+       (/*LINTED*/sizeof(struct sockcred) + (sizeof(gid_t) * ((ngrps) - 1)))
 #endif /* _NETBSD_SOURCE */
 
 



Home | Main Index | Thread Index | Old Index