Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hppa/hppa Avoid UB (shift of negative number)



details:   https://anonhg.NetBSD.org/src/rev/e41ad5d72ae1
branches:  trunk
changeset: 829990:e41ad5d72ae1
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Feb 21 10:42:16 2018 +0000

description:
Avoid UB (shift of negative number)

diffstat:

 sys/arch/hppa/hppa/db_disasm.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (48 lines):

diff -r 4571702fa9db -r e41ad5d72ae1 sys/arch/hppa/hppa/db_disasm.c
--- a/sys/arch/hppa/hppa/db_disasm.c    Wed Feb 21 09:47:37 2018 +0000
+++ b/sys/arch/hppa/hppa/db_disasm.c    Wed Feb 21 10:42:16 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: db_disasm.c,v 1.16 2012/01/18 09:35:48 skrll Exp $     */
+/*     $NetBSD: db_disasm.c,v 1.17 2018/02/21 10:42:16 skrll Exp $     */
 
 /*     $OpenBSD: db_disasm.c,v 1.9 2000/04/18 20:02:45 mickey Exp $    */
 
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.16 2012/01/18 09:35:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.17 2018/02/21 10:42:16 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -865,23 +865,23 @@
 #define        Bi2(i)          BitfR(i,6,13,_b613)
 
 /* fragmented field collating macros */
-#define        Ima5(i)         (Ima5S(i) ? Ima5M(i) | (-1<<4) : Ima5M(i))
+#define        Ima5(i)         (Ima5S(i) ? Ima5M(i) | (int)(~__BITS(3,0)) : Ima5M(i))
 
-#define        Imc5(i)         (Imc5S(i) ? Imc5M(i) | (-1<<4) : Imc5M(i))
+#define        Imc5(i)         (Imc5S(i) ? Imc5M(i) | (int)(~__BITS(3,0)) : Imc5M(i))
 
-#define        Disp(i)         (DispS(i) ?   DispM(i) | (-1<<13) : DispM(i))
+#define        Disp(i)         (DispS(i) ?   DispM(i) | (int)(~__BITS(12,0)) : DispM(i))
 
 #define        Im21(i)         (Im21S(i) << 31 | Im21H(i) << 20 | Im21M1(i) << 18 | \
                                Im21M2(i) << 13 | Im21L(i) << 11)
 
-#define        Im11(i)         (Im11S(i) ?   Im11M(i) | (-1<<10) : Im11M(i))
+#define        Im11(i)         (Im11S(i) ?   Im11M(i) | (int)(~__BITS(9,0)) : Im11M(i))
 
 #define        Bdisp(i)        ((OffS(i) ? (Off5(i)<<11 | Off11L(i)<<10|Off11H(i)) \
-/* branch displacement (bytes) */      | (-1 << 16)                    \
+/* branch displacement (bytes) */      | (int)(~__BITS(15,0))                  \
                                  : (Off5(i)<<11|Off11L(i)<<10|Off11H(i))) << 2)
 
 #define        Cbdisp(i)       ((OffS(i) ?   (Off11L(i) << 10 | Off11H(i)) \
- /* compare/branch disp (bytes) */ | (-1 << 11)                        \
+ /* compare/branch disp (bytes) */ | (int)(~__BITS(10,0))              \
                                  :    Off11L(i) << 10 | Off11H(i)) << 2)
 
 #define        Sr(i)           (SrH(i)<<2 | SrL(i))



Home | Main Index | Thread Index | Old Index