Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Try to appease KUBSan in sys/sys/wait.h in W_EXITCODE()
details: https://anonhg.NetBSD.org/src/rev/496a40818256
branches: trunk
changeset: 362966:496a40818256
user: kamil <kamil%NetBSD.org@localhost>
date: Tue Jul 03 22:38:33 2018 +0000
description:
Try to appease KUBSan in sys/sys/wait.h in W_EXITCODE()
Cast return value that is stored as int to unsigned int in order to
appease the << 8 operation. In case of a ret=-1, this cast is papering
things over or replacing UB with an implementation specific behavior.
There is a reverse operation with the same papering things over:
WEXITSTATUS(x) ((int)(((unsigned int)_W_INT(x)) >> 8) & 0xff)
No functional change intended.
Detected with Kernel Undefined Behavior Sanitizer.
Reported by <Harry Pantazis>
diffstat:
sys/sys/wait.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diffs (18 lines):
diff -r 42d0d4271801 -r 496a40818256 sys/sys/wait.h
--- a/sys/sys/wait.h Tue Jul 03 21:12:10 2018 +0000
+++ b/sys/sys/wait.h Tue Jul 03 22:38:33 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wait.h,v 1.35 2016/11/10 18:35:17 christos Exp $ */
+/* $NetBSD: wait.h,v 1.36 2018/07/03 22:38:33 kamil Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993, 1994
@@ -69,7 +69,7 @@
#define WCOREFLAG 0200
#define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
-#define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
+#define W_EXITCODE(ret, sig) ((unsigned int)(ret) << 8 | (sig))
#define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
#define W_CONTCODE() (_WCONTINUED)
#endif
Home |
Main Index |
Thread Index |
Old Index