apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Branko ─îibej <br...@apache.org>
Subject Re: [PATCH] How to Use strcmp to Check for Equality Without Confusing Your Fellow Code, Or: Isn't There a Macro for That?
Date Wed, 20 Oct 2010 05:42:59 GMT
 On 20.10.2010 07:15, tomas@tuxteam.de wrote:
> On Tue, Oct 19, 2010 at 06:36:08PM +0200, Malte S. Stretz wrote:
> > Hi folks,
>
> > I recently started to hack on the Apache HTTPD codebase and immediately
> > stumbled upon one of my personal code smells:  The usage of strcmp and
> > friends and how strings are compared for equality.
>
> > I know it is hard to agree on which variant is best [...]
>
> Just a personal data point from a newcomer and mostly lurker: my
> preferences are, in that order:
>
>   strcmp(...) == 0
>
>   !strcmp(...)
>
>   macro

And my personal first is

    0 == strcmp(...)

because the "..." can be very long and then it's hard to see the "== 0"
at the end.
Agree that macros are worst in this case because they quite handily hide
the meaning of the expression.

-- Brane

Mime
View raw message