nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] proposed patch for shell metacharacter failure in nmh-


From: Tom Lane
Subject: Re: [Nmh-workers] proposed patch for shell metacharacter failure in nmh-1.7
Date: Mon, 15 Jan 2018 01:15:10 -0500

Paul Vixie <address@hidden> writes:
> Ken Hornstein wrote:
>>> pointers aren't booleans. in BSD style as used in BIND, this would be:
>>>     while ((pp = strchr(pp, '\'')) != NULL && buflen > 3) {

>> Forgive my stupidity ... but this is just a matter of style, correct?

> the same underlying machine code will be generated.

Yeah, it's legal C ...

> i would rather give the compiler an extra chance to yell at me. pointers 
> aren't booleans, in spite of C's ability to treat them that way.

Exactly --- there's a lot of distance between legal C and advisable C.

In this example, for instance, the comparison to NULL makes it clearer
that you did not mean to write

        while ((pp == strchr (pp, '\'')) && buflen > 3) {

Your compiler may or may not whine about the shorter coding, depending
on which compiler it is and how high you've cranked its warning options.
But there are a lot of static analysis tools that will whine about it
in any case, and usually that stylistic advice is worth taking.  C in
the raw is a bear trap waiting to take your foot off --- anything you
can do to make mistakes more obvious is worth doing.

                        regards, tom lane



reply via email to

[Prev in Thread] Current Thread [Next in Thread]