Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <20241001134139.619@kylheku.com>
Deutsch   English   Français   Italiano  
<20241001134139.619@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.lang.c
Subject: Re: Code guidelines
Date: Tue, 1 Oct 2024 21:39:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <20241001134139.619@kylheku.com>
References: <vb6v1t$3b5mb$1@dont-email.me> <vb726n$3b4rq$1@dont-email.me>
 <vb736j$3b5mb$2@dont-email.me> <vb75g9$3bntp$1@dont-email.me>
 <vb77tn$3bu07$3@dont-email.me> <vb7d6l$3d5mv$1@dont-email.me>
 <vdgjkc$2mhpi$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 01 Oct 2024 23:39:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="522f7606726274378d45f3c566bfa2c1";
	logging-data="3050697"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+Rh/Ckub8ksNmDJVILvjn+SKFhU1h4lZU="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:osFrqtjf38Cc4A7R4mRNUyJwAYc=
Bytes: 2180

On 2024-10-01, Vir Campestris <vir.campestris@invalid.invalid> wrote:
> On 03/09/2024 17:23, Thiago Adams wrote:
><snip>
>> 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.

How about:

  #define vassert(x) (assert(x), 1)

  if (obj->member1 &&
      vassert(obj->member1->member2) &&
      obj->member1->member2->member3)

If NDEBUG is defined, that just reduces to 1, and is optimized
away. If NDEBUG is absent, the null pointer crash is replaced
by an assertion failure.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca