Refine integer signedness use for static analyizers (#24)
diff --git a/src/UsefulBuf.c b/src/UsefulBuf.c
index 1d13f10..a96f74e 100644
--- a/src/UsefulBuf.c
+++ b/src/UsefulBuf.c
@@ -41,7 +41,8 @@
when who what, where, why
-------- ---- ---------------------------------------------------
- 01/08/2020 llundblade Documentation corrections & improved code formatting.
+ 01/28/2020 llundblade Refine integer signedness to quiet static analysis.
+ 01/08/2020 llundblade Documentation corrections & improved code formatting.
11/08/2019 llundblade Re check pointer math and update comments
3/6/2019 llundblade Add UsefulBuf_IsValue()
09/07/17 llundbla Fix critical bug in UsefulBuf_Find() -- a read off
@@ -109,7 +110,8 @@
for(const uint8_t *p = UB.ptr; p < pEnd; p++) {
if(*p != uValue) {
/* Byte didn't match */
- return p - (uint8_t *)UB.ptr;
+ /* Cast from signed to unsigned . Safe because the loop increments.*/
+ return (size_t)(p - (uint8_t *)UB.ptr);
}
}