util: fix -Wshorten-64-to-32 warnings#12534
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12534 +/- ##
=======================================
Coverage 80.68% 80.69%
=======================================
Files 925 925
Lines 258914 258944 +30
=======================================
+ Hits 208914 208943 +29
- Misses 50000 50001 +1
Flags with carried forward coverage won't be shown. Click here to find out more. |
|
Information: QA ran without warnings. Pipeline 24636 |
| char *sep = strchr(lnode->val, '-'); | ||
| char *end; | ||
| a = strtoul(lnode->val, &end, 10); | ||
| a = (int)strtoul(lnode->val, &end, 10); |
There was a problem hiding this comment.
this is a bit odd, downcasting strtoul to int... should we just use atoi? Or one of our parsing wrappers perhaps
There was a problem hiding this comment.
Trying StringParseUint32
| if (data_offset < sbblen) { | ||
| *data = region->buf; | ||
| *data_len = sbblen - data_offset; | ||
| DEBUG_VALIDATE_BUG_ON(sbblen - data_offset > UINT32_MAX); |
There was a problem hiding this comment.
these checks are a bit ugly, would it make sense to have a dedicated macro to hide the check details?
untested and with a poor name, but something like
U32_SUB_CHECK(sbblen, data_offset);
#define U32_SUB_CHECK(a,b) \
DEBUG_VALIDATE_BUG_ON((a) - (b) > UINT32_MAX); \
(a) - (b)There was a problem hiding this comment.
improving some go these checks by making data_offset a u32 in the first place
|
Next in #12624 |
Link to redmine ticket:
https://redmine.openinfosecfoundation.org/issues/6186
Describe changes:
-Wshorten-64-to-32warnings for some files : utilOne commit of #9840
#12481 improved after review
Still to do afterwards :