Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/rasops For kUBSan, avoid undefined behaviors even if...



details:   https://anonhg.NetBSD.org/src/rev/429492b1af58
branches:  trunk
changeset: 457942:429492b1af58
user:      rin <rin%NetBSD.org@localhost>
date:      Thu Jul 25 00:55:13 2019 +0000

description:
For kUBSan, avoid undefined behaviors even if harmless.
No functional changes intended.

Requested by uwe.

diffstat:

 sys/dev/rasops/rasops.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r f9fe165163a4 -r 429492b1af58 sys/dev/rasops/rasops.c
--- a/sys/dev/rasops/rasops.c   Thu Jul 25 00:48:55 2019 +0000
+++ b/sys/dev/rasops/rasops.c   Thu Jul 25 00:55:13 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rasops.c,v 1.86 2019/07/24 19:33:35 rin Exp $ */
+/*      $NetBSD: rasops.c,v 1.87 2019/07/25 00:55:13 rin Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.86 2019/07/24 19:33:35 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rasops.c,v 1.87 2019/07/25 00:55:13 rin Exp $");
 
 #include "opt_rasops.h"
 #include "rasops_glue.h"
@@ -1062,8 +1062,8 @@
        rp = (uint8_t *)((uintptr_t)rp & ~3);
        hrp = (uint8_t *)((uintptr_t)hrp & ~3);
 
-       msk1 = be32toh(0xffffffffU >> (32 - (8 * slop1)));
-       msk2 = be32toh(0xffffffffU << (32 - (8 * slop2)));
+       msk1 = !slop1 ? 0 : be32toh(0xffffffffU >> (32 - (8 * slop1)));
+       msk2 = !slop2 ? 0 : be32toh(0xffffffffU << (32 - (8 * slop2)));
 
        while (height--) {
                dp = rp;



Home | Main Index | Thread Index | Old Index