From:  Vir Campestris <vir.campestris@invalid.invalid>
Date:  01 Oct 2024 18:41:16 Hong Kong Time
Newsgroup:  news.alt119.net/comp.lang.c
Subject:  

Re: Code guidelines

NNTP-Posting-Host:  null

On 03/09/2024 17:23, Thiago Adams wrote:

> but...maybe, is better to be a little redundant here?
> I think I prefer to leave "obj->member1->member2 && " even if I know
> it should not be null.
> 
> if (obj->member1 &&
>      obj->member1->member2 &&
>      obj->member1->member2->member3)
> {
> 
> }

I think I'd prefer to _omit_ the check that obj->member1->member2 isn't 
null.

If the code is running correctly that check will never trigger, and is 
redundant, and will slow things slightly.

But if the code is not running correctly it will conceal the bug by 
preventing the crash.

But circumstances may vary. You probably don't want to crash an 
autopilot if at all possible!

Andy