[MERGED] osmo-pcu[master]: mslot_class: two more: use uint32_t to shift 1 << 31

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Mar 28 13:02:18 UTC 2018


Neels Hofmeyr has submitted this change and it was merged.

Change subject: mslot_class: two more: use uint32_t to shift 1 << 31
......................................................................


mslot_class: two more: use uint32_t to shift 1 << 31

Avoid runtime error seen on jenkins admin-deb9build slave, when building
osmo-pcu with_dsp=None,with_vty=False, during ts_alloc and tbf regression
tests:

+../../../src/mslot_class.c:271:36: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
+../../../src/mslot_class.c:272:22: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

This time it seems that these are all.

The master-osmo-pcu breaks on this since moving to a debian9 build slave.

Change-Id: I976a1dca9da19a05afc85a17b7ba60545b7bc1e5
---
M src/mslot_class.c
1 file changed, 2 insertions(+), 2 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/mslot_class.c b/src/mslot_class.c
index 9d54afe..ff40f29 100644
--- a/src/mslot_class.c
+++ b/src/mslot_class.c
@@ -268,8 +268,8 @@
 
 bool mslot_test_and_set_bit(uint32_t *bits, size_t elem)
 {
-	bool was_set = bits[elem/32] & (1 << (elem % 32));
-	bits[elem/32] |= (1 << (elem % 32));
+	bool was_set = bits[elem/32] & (((uint32_t)1) << (elem % 32));
+	bits[elem/32] |= (((uint32_t)1) << (elem % 32));
 
 	return was_set;
 }

-- 
To view, visit https://gerrit.osmocom.org/7552
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I976a1dca9da19a05afc85a17b7ba60545b7bc1e5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list