Bad syntax

Came across this one in a piece of C code.

(conditionflag & STATUSBIT) ?
(KdPrint(xxxx)) : 0;

Edited [ 2005-08-04, 19:42 Pete ] There was no code making use of the result of the ?: operation.
This piece of code is terrible from both a readability and functionality perspective. If the return type of the function is changed to a void, then there won’t be a valid left hand side for the evaluation to function correctly, from a readability perspective the developer split the code over two lines, which made it ripe for the more legible form of:

if (conditionflag & STATUSBIT)
(KdPrint(xxxx));

Ah well, you can’t boss everyone around all of the time I suppose.

One Reply to “Bad syntax”

Comments are closed.