Better to use an OR or an AND when checking for NULLs in C if statements?

Posted by Crazy Chenz on Stack Overflow See other posts from Stack Overflow or by Crazy Chenz
Published on 2010-06-17T12:15:57Z Indexed on 2010/06/17 12:23 UTC
Read the original article Hit count: 179

Filed under:

Came across a line in OpenSSL that made me do a double take...

if (!*pos)
  return NULL;
if (!*pos || ((*pos)->flags == FLAGS))
  return blah;

Is there a (performance/security/concurrecy) difference in doing that instead of:

if (!*pos) 
  return NULL;
if (*pos && ((*pos)->flags == FLAGS))
  return blah;

Thanks, Chenz

© Stack Overflow or respective owner

Related posts about c