From d3f93746a84d4bd49c87a3f01e90143b7cc3e896 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 26 Feb 2023 11:52:50 -0800 Subject: [PATCH] 1<<31 upsets ubsan --- modules/database/src/std/rec/mbboDirectRecord.c | 2 +- modules/database/test/std/rec/mbbioDirectTest.c | 2 +- modules/libcom/src/yacc/closure.c | 4 ++-- modules/libcom/src/yacc/warshall.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/database/src/std/rec/mbboDirectRecord.c b/modules/database/src/std/rec/mbboDirectRecord.c index c41cc6d7a..6d3347abb 100644 --- a/modules/database/src/std/rec/mbboDirectRecord.c +++ b/modules/database/src/std/rec/mbboDirectRecord.c @@ -271,7 +271,7 @@ static long special(DBADDR *paddr, int after) } else if(after==1 && fieldIndex >= mbboDirectRecordB0 && fieldIndex <= mbboDirectRecordB1F) { /* Adjust VAL corresponding to the bit changed */ epicsUInt8 *pBn = (epicsUInt8 *) paddr->pfield; - epicsUInt32 bit = 1 << (pBn - &prec->b0); + epicsUInt32 bit = 1u << (pBn - &prec->b0); /* Because this is !(VAL and PP), dbPut() will always post a monitor on this B* field * after we return. We must keep track of this change separately from MLST to handle diff --git a/modules/database/test/std/rec/mbbioDirectTest.c b/modules/database/test/std/rec/mbbioDirectTest.c index 304217d37..ed2c5c39d 100644 --- a/modules/database/test/std/rec/mbbioDirectTest.c +++ b/modules/database/test/std/rec/mbbioDirectTest.c @@ -123,7 +123,7 @@ MAIN(mbbioDirectTest) testDiag("##### clear bit 31 (0x1f) #####"); putN("do%u.B1F", N, 0); - value &= ~(1<<31); + value &= ~(1u<<31u); testN("val%d", N, value); testmbbioRecords(N, value); diff --git a/modules/libcom/src/yacc/closure.c b/modules/libcom/src/yacc/closure.c index 548b93889..5d7c0f5d4 100644 --- a/modules/libcom/src/yacc/closure.c +++ b/modules/libcom/src/yacc/closure.c @@ -85,7 +85,7 @@ set_first_derives(void) k = 0; } - if (cword & (1 << k)) + if (cword & (1u << k)) { rp = derives[j]; while ((rule = *rp++) >= 0) @@ -152,7 +152,7 @@ closure(short int *nucleus, int n) { for (i = 0; i < BITS_PER_WORD; ++i) { - if (word & (1 << i)) + if (word & (1u << i)) { itemno = rrhs[ruleno+i]; while (csp < csend && *csp < itemno) diff --git a/modules/libcom/src/yacc/warshall.c b/modules/libcom/src/yacc/warshall.c index 186fdbce9..1362e49cb 100644 --- a/modules/libcom/src/yacc/warshall.c +++ b/modules/libcom/src/yacc/warshall.c @@ -26,7 +26,7 @@ transitive_closure(unsigned int *R, int n) while (rowj < relend) { - if (*ccol & (1 << i)) + if (*ccol & (1u << i)) { rp = rowi; rend = rowj + rowsize; @@ -68,7 +68,7 @@ reflexive_transitive_closure(unsigned int *R, int n) rp = R; while (rp < relend) { - *rp |= (1 << i); + *rp |= (1u << i); if (++i >= BITS_PER_WORD) { i = 0;