[SystemSafety] OpenSSL Bug

David Haworth david.haworth at elektrobit.com
Wed Apr 16 13:08:33 CEST 2014


Hi,

I was trying to keep out of this, but I'm starting to get sick of
this particular example.

    if ((a = check()) = SUCCESS) { ... }

fails to compile because (a = check()) is not an lvalue.

So

    if ((a = check()) == SUCCESS) { ... }

is a perfectly safe construct. Unless, of course, what you really
intended to write was

    if ((a == check()) == SUCCESS) { ... }

in which case you should take yourself out and shoot yourself
for comparing an effectively boolean result with a specific
numerical value.

@Steve: this isn't aimed at you especially - you just happen to 
be the most recent person to quote this nonsensical example.

Dave


On 2014-04-16 10:17:41 +0000, Steve Tockey wrote:
> 
> I'm not arguing for or against C, but I have seen coding standards that
> prohibit:
> 
> if ((a = check()) == SUCCESS) { ... }
> 
> 
> 
> They require instead:
> 
> if ( SUCCESS == (a = check()) ) { ... }
> 
> 
> 
> Simply moving the constant to the left side makes it an ill-formed
> expression if the "==" is accidentally switched for "=":
> 
> if ( SUCCESS = (a = check()) ) { ... }
> 
> 
> 
> 
> -- steve

-- 
David Haworth B.Sc.(Hons.), OS Kernel Developer    david.haworth at elektrobit.com
Tel: +49 9131 7701-6154     Fax: -6333                  Keys: keyserver.pgp.com
Elektrobit Automotive GmbH           Am Wolfsmantel 46, 91058 Erlangen, Germany
Geschäftsführer: Alexander Kocher, Gregor Zink       Amtsgericht Fürth HRB 4886
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://lists.techfak.uni-bielefeld.de/mailman/private/systemsafety/attachments/20140416/a3bf026e/attachment.pgp>


More information about the systemsafety mailing list