🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2036

Re: Bad Style Contest - We Have a Winner!

#2036
From: Hans Steffani
Date: Fri, 16 Feb 1996 15:51
41 lines
1692 bytes
kremser@sbox.tu-graz.ac.at (Herbert Kremser) writes:
>If i see

>  if (p != NULL && p->is_ok != 0)

>i have to think a bit longer what really is meant, compared to

>  if (p && p->is_ok)

Here I prefer 
 if( p!= NULL && p->is_ok )

because
 p represents a pointer which may conatain any value
 p->is_ok represents a boolean value (yes, I know there is
 no boolean type in C) which can either be 0 (False) or not 0 (True).


>Ok, no ! in here, so

>  if (p == NULL || p->is_ok == 0)
>compared to
>  if (!p || !p->is_ok)

This is no good example as the second part of the if clause
will dereference a NULL pointer which fails on "real Systems".

Taking
 if( p == certain_pointer || p->is_ok == 0 )
I would take
 if( p == certain_pointer || !p->is_ok )

You see the problem? p cannot be checked sensfully in terms of
equal or not equal.

h.f.s.
--
Hans Friedrich Steffani
Institut fuer Elektrische Maschinen und Antriebe
TU Chemnitz-Zwickau
e-mail: hans.steffani@e-technik.tu-chemnitz.de
Technical Details
Message-ID: <4g295n$qsg@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4dj2hq$l9e@solutions.solon.com> <4e5oad$664@solutions.solon.com> <4e7tik$pm@solutions.solon.com> <4e9ets$99q@solutions.solon.com> <4ecou8$orh@solutions.solon.com> <4fa79e$2lp@solutions.solon.com> <4fbfvt$9op@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: hans.steffani@e-technik.tu-chemnitz.de (Hans Steffani)
Newsgroups: comp.lang.c.moderated
Subject: Re: Bad Style Contest - We Have a Winner!
Date: 16 Feb 1996 09:51:19 -0600
Organization: University of Technology Chemnitz, FRG
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4g295n$qsg@solutions.solon.com>
References: <4dj2hq$l9e@solutions.solon.com> <4e5oad$664@solutions.solon.com> <4e7tik$pm@solutions.solon.com> <4e9ets$99q@solutions.solon.com> <4ecou8$orh@solutions.solon.com> <4fa79e$2lp@solutions.solon.com> <4fbfvt$9op@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com