From 7bfc6aa754ed34ac7abf1690c1e80fe85a5afc4e Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Thu, 25 Aug 2022 22:30:03 +0300 Subject: [PATCH] selectable_int: introduce more checks --- src/openpower/decoder/selectable_int.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/openpower/decoder/selectable_int.py b/src/openpower/decoder/selectable_int.py index d3caac30..46477509 100644 --- a/src/openpower/decoder/selectable_int.py +++ b/src/openpower/decoder/selectable_int.py @@ -97,6 +97,8 @@ class FieldSelectableInt: return selectconcat(*[self.si[x] for x in key]) elif isinstance(key, (tuple, list, range)): return FieldSelectableInt(si=self, br=key) + else: + raise ValueError(key) def __setitem__(self, key, value): if isinstance(key, SelectableInt): @@ -379,6 +381,8 @@ class SelectableInt: value = (self.value >> start) & mask log("getitem", stop, start, self.bits, hex(self.value), value) return SelectableInt(value, bits) + else: + raise ValueError(value) def __setitem__(self, key, value): if isinstance(key, SelectableInt): @@ -420,6 +424,8 @@ class SelectableInt: mask = ((1 << bits) - 1) << start value = value << start self.value = (self.value & ~mask) | (value & mask) + else: + raise ValueError(key) def __ge__(self, other): if isinstance(other, FieldSelectableInt): -- 2.30.2