Wireshark-commits: [Wireshark-commits] master 19c0b8b: Don't use "== {TRUE, FALSE}" when testing wh
From: Wireshark code review <code-review-do-not-reply@xxxxxxxxxxxxx>
Date: Fri, 27 May 2016 06:47:38 +0000 (UTC)
URL: https://code.wireshark.org/review/gitweb?p=wireshark.git;a=commit;h=19c0b8bbfd9712ff3182a119f5daeac33a7732d5
Submitter: Guy Harris (guy@xxxxxxxxxxxx)
Changed: branch: master
Repository: wireshark

Commits:

19c0b8b by Guy Harris (guy@xxxxxxxxxxxx):

    Don't use "== {TRUE,FALSE}" when testing whether a Boolean is true or false.
    
    "if (boolean)" suffices to test for true, and "if (!boolean)" suffices
    to test for false.
    
    Most of the time, explicitly comparing against TRUE or FALSE is
    harmless, although possibly slightly less efficient, as you're
    explicitly testing against 1 rather than testing for "not zero".
    
    *However*, if you want to test whether a given bit is set in a flags
    field, "if ((flags & flagbit) == TRUE)" *DOES NOT WORK* unless "flagbit"
    is equal to 1, because TRUE is equal to 1, and if "flagbit" is not equal
    to 1, "flags & flagbit" will *NEVER* be equal to 1.
    
    So comparing "== TRUE" is a bad habit to get into, as it might lead to
    its use when doing bit testing.
    
    While we're at it, clean up some other tests:
    
    	"if (!(x == FALSE))" really means "x is true", so write it as
    	such, i.e. "if (x)";
    
    		if (a && b)
    			do this;
    		if (a && !b)
    			do that;
    
    	reads better as
    
    		if (a) {
    			if (b)
    				do this
    			else
    				do that
    		}
    
    	when doing bit testing, there's no need to shift the bit, just
    	test it (and, no, that doesn't conflict with the bit about TRUE
    	being 1 - *just test the bit*, it's the standard C idiom).
    
    Fixes CID 1362119.
    
    Change-Id: I011154caae45307796ffd270d265c05a2533b1db
    Reviewed-on: https://code.wireshark.org/review/15585
    Reviewed-by: Guy Harris <guy@xxxxxxxxxxxx>
    

Actions performed:

    from  1a5b05d   Show the reserved fields in AAPL buffers.
    adds  19c0b8b   Don't use "== {TRUE,FALSE}" when testing whether a Boolean is true or false.


Summary of changes:
 plugins/profinet/packet-dcerpc-pn-io.c |   58 +++++++++++++++++---------------
 1 file changed, 30 insertions(+), 28 deletions(-)