coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] echo: pacify Oracle Studio 12.6


From: Bob Proulx
Subject: Re: [PATCH 1/2] echo: pacify Oracle Studio 12.6
Date: Mon, 1 Jun 2020 17:44:52 -0600

Paul Eggert wrote:
> * src/echo.c (main): Don’t assign pointer to bool.
> This is well-defined in C99, but is arguably bad style
> and Oracle Studio 12.6 complains.
...
> +  bool posixly_correct = !!getenv ("POSIXLY_CORRECT");

Of course this is fine.  But because char *getenv() returns a pointer
it just has this feeling of expressing frustration with the compiler
seeing the !! there.  It feels like an obvious cast silencing a
compiler warning.  Perhaps that is the intent? :-)

  RETURN VALUE
       The getenv() function returns a pointer to the value in the
       environment, or NULL if there is no match.

Just as a soft comment that isn't very strong if it were me I would
use a comparison against a pointer which produced a boolean result and
that boolean result used to assign to a bool.  It just feels to me
like more of the types are more obvious this way.  And no cast of any
type is either implicit or explicit.

  bool posixly_correct = getenv ("POSIXLY_CORRECT") != NULL;

But of course it's all a matter of style.

Bob



reply via email to

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