summaryrefslogtreecommitdiff
path: root/bits.c
diff options
context:
space:
mode:
authorBernd Zeimetz <bernd@bzed.de>2013-12-07 18:46:46 +0100
committerBernd Zeimetz <bernd@bzed.de>2013-12-07 18:46:46 +0100
commita496a59c81173881900d976be35752787f4ab38c (patch)
tree374863c251202d7a0f5dceab0b10161726cf862b /bits.c
parent707dfb70f947f04ab8dcdf5c8e4909399dea2790 (diff)
downloadgpsd-a496a59c81173881900d976be35752787f4ab38c.tar.gz
Avoid a possible logic error as reported by scan-build.
Diffstat (limited to 'bits.c')
-rw-r--r--bits.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/bits.c b/bits.c
index 4b6015e9..8db4a4aa 100644
--- a/bits.c
+++ b/bits.c
@@ -63,6 +63,11 @@ int64_t sbits(signed char buf[], unsigned int start, unsigned int width, bool le
{
uint64_t fld = ubits((unsigned char *)buf, start, width, le);
+ /* ensure width > 0 as the result of
+ 1LL << (width - 1)
+ is undefined for width <= 0 */
+ assert(width > 0);
+
/*@ +relaxtypes */
if (fld & (1LL << (width - 1))) {
/*@ -shiftimplementation @*/