RafaGago / mini-async-log

Non bloated asynchronous logger
Other
220 stars 20 forks source link

static analysis fixes #18

Closed ebudai closed 7 years ago

ebudai commented 7 years ago

(found + 1) != 0 can only be true if found overflows, which is UB. -1 >> 1 is UB.

The rest are self-explanatory.

RafaGago commented 7 years ago

Hello!

Thanks for the patch!

I did the modifications locally:

https://github.com/RafaGago/mini-async-log/commit/ffc38ffdf393119f62e7daa9bd3ff5868e44c6a2

That (found + 1) was a bug (missing the asterisk: *(found + 1)). The forgotten zero check on "is_multiple_safe" too.

I did remove the "mem_printf_written" function with that ugly ~(-2), which was unused anyways.

ebudai commented 7 years ago

*(found + 1) and found[1] are the same, but the latter is easier to read, imo.

RafaGago commented 7 years ago

Yes, they are. Note that your changes are already merged on the link posted above.

https://github.com/RafaGago/mini-async-log/commits/master