Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

if(IN_RANGE_CLOSED(dw_result,0,WHATEVER))

Build the appropriate model for IN_RANGE, and done.

Has the benefit that you explicitly state the type of range (open|closed|half-open[LR]), so you'll be a bit more likely to think about the edge cases.

Is it painful? Yes. I'd rather take that pain than debugging crash reports, though. (YMMV - it certainly depends on what you are building, how large your audience is, and what the consequences of a crash are)



To be honest, that's really ugly to me, and it requires me to remind myself of exactly what that macro is. I'm definitely not willing to change my code style solely to satisfy a static checker's zero-impact 'bug'.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: