Closed pavelxdd closed 2 years ago
Thanks, I checked it before with clang analyzer, but the last two issues were not detected.
Fixed at: https://github.com/ibireme/yyjson/commit/5cb87def66ebba024e7bb8f42ecb648649f7ffde
The repeat16_incr will never be executed
warning is not accurate, the code will be executed when the repeat16_incr
macro is expanded.
There are some issues I found when checking yyjson with
cppcheck
.https://github.com/ibireme/yyjson/blob/94e47ab18019129124099036ac1a1a02c5fc9b52/src/yyjson.h#L4156 The assignment of
pre_key
is useless, since it's never used.https://github.com/ibireme/yyjson/blob/94e47ab18019129124099036ac1a1a02c5fc9b52/src/yyjson.c#L4129-L4130 https://github.com/ibireme/yyjson/blob/94e47ab18019129124099036ac1a1a02c5fc9b52/src/yyjson.c#L6560-L6562 Expressions after
goto
orreturn
are unreachable.repeat16_incr
will never be executed.https://github.com/ibireme/yyjson/blob/94e47ab18019129124099036ac1a1a02c5fc9b52/src/yyjson.c#L5524
(file_size + 1) < 0
is always false. If you wanted to check forlong
overflow then this is undefined bahaviour (signed integer overflow is UB).https://github.com/ibireme/yyjson/blob/94e47ab18019129124099036ac1a1a02c5fc9b52/src/yyjson.c#L5482
hdr
is always notNULL
, since it's checked aftermalloc
.