Source-Changes-HG archive

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

[src/trunk]: src/sys/sys Fix uninitialized, caught by llvm. Tuck variables in...



details:   https://anonhg.NetBSD.org/src/rev/c1cf7e21fc6d
branches:  trunk
changeset: 975401:c1cf7e21fc6d
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Aug 28 12:43:24 2020 +0000

description:
Fix uninitialized, caught by llvm. Tuck variables in blocks where they are
needed.

diffstat:

 sys/sys/systm.h |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r 773f34053972 -r c1cf7e21fc6d sys/sys/systm.h
--- a/sys/sys/systm.h   Fri Aug 28 12:41:17 2020 +0000
+++ b/sys/sys/systm.h   Fri Aug 28 12:43:24 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: systm.h,v 1.297 2020/08/27 14:11:57 riastradh Exp $    */
+/*     $NetBSD: systm.h,v 1.298 2020/08/28 12:43:24 christos Exp $     */
 
 /*-
  * Copyright (c) 1982, 1988, 1991, 1993
@@ -201,12 +201,13 @@
 
 #define COND_SET_CPTR(dst, src, allow) \
        do { \
-               void *__v; \
                if (allow) \
                        dst = src; \
-               else \
+               else { \
+                       void *__v; \
                        hash_value(&__v, sizeof(__v), &src, sizeof(src)); \
-               dst = __v; \
+                       dst = __v; \
+               } \
        } while (/*CONSTCOND*/0)
 
 #define COND_SET_PTR(dst, src, allow) \
@@ -219,11 +220,12 @@
 
 #define COND_SET_VALUE(dst, src, allow)        \
        do { \
-               uint64_t __v = src; \
                if (allow) \
                        dst = src; \
-               else \
+               else { \
+                       uint64_t __v = src; \
                        hash_value(&dst, sizeof(dst), &__v, sizeof(__v)); \
+               } \
        } while (/*CONSTCOND*/0)
 
 void   hash_value(void *, size_t, const void *, size_t);



Home | Main Index | Thread Index | Old Index