redis-cli: Assert > 0 before dividing, to silence warning by tool#9396
Conversation
Also make sure function can't return NULL by another assert.
|
so replacing a division by 0 with an assertion? what's the difference? (SIGFPE vs SIGABRT?) i did do a similar thing in redis recently, and my aim was for the tests to be able to easily distinguish between a crash by signal, and an assertion (also added my point is, if this is a completely dead code, why bother? |
|
It can't happen and an assert is just a way to make that more clear in the code. If the function starts to be used in another place, maybe it can happen. @oranagra if you think it's useless, feel free to close the PR and the issue. :-) If the warning is from an analysis tool we want to use, we'd want to silence the false warnings. Some tools out there are quite good, but I don't know which one this was. @yiyuaner which tool was it? |
It's from an ongoing research project. I don't know the coding practice of redis, but maybe this warning reveals at least dead code (if not potential bugs). Maybe an explicit |
oranagra
left a comment
There was a problem hiding this comment.
ok, i'll take it.
i.e. i'll consider it a clarification in the code, not a fix..
|
i only not notice the title of the PR (i think i didn't noticed before that it mentions the reason is to silence a warning) |
…dis#9396) Also make sure function can't return NULL by another assert.
Also make sure function can't return NULL by another assert.
Fixes #9383.