Wireshark-dev: [Wireshark-dev] ** CID 280353: Operands don't affect result (CONSTANT_EXPRESSION
From: Toralf Förster <toralf.foerster@xxxxxx>
Date: Sun, 09 Feb 2014 10:48:44 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Today coverity told me :

________________________________________________________________________________________________________
*** CID 280353:  Operands don't affect result  (CONSTANT_EXPRESSION_RESULT)
/text2pcap.c: 522 in in_checksum()
516             addr++;
517             count -= 2;
518         }
519     
520         /*  Add left-over byte, if any */
521         if (count > 0)
>>>     CID 280353:  Operands don't affect result  (CONSTANT_EXPRESSION_RESULT)
>>>     "(guint16)*((guint8 *)addr) >> 8" is 0 regardless of the values of its operands. This occurs as the bitwise first operand of '|'.
522             sum += g_ntohs(* (guint8 *) addr);
523     
524         /*  Fold 32-bit sum to 16 bits */
525         while (sum>>16)
526             sum = (sum & 0xffff) + (sum >> 16);
527     


while just git grep'ing for "g_ntohs" I stumbled in doc/README.developer over this sentence
"Instead, use "g_ntohs()", "g_ntohl()", "g_htons()", and "g_htonl() those are declared by <glib.h>"
b/c I did not found any glib.h where those functions are declared.

Furthermore I wonder why an undefined value in epan/crypt/airpdcap_interop.h (around line 98) :

#ifndef ntohs
#undef     ntohs      <--------------
#define ntohs(value)    g_ntohs(value)
#endif

has to be undef again ? Or does "#ifndef" also check for a defined, but empty variable ?

- -- 
MfG/Sincerely
Toralf Förster
pgp finger print:1A37 6F99 4A9D 026F 13E2 4DCF C4EA CDDE 0076 E94E
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iF4EAREIAAYFAlL3TvwACgkQxOrN3gB26U72sgD/S9GmxQNfefvyGFBxJzcq/nuC
CKR1ymBHzfGhfUtza2oBAI7RkshioktDhz3XiexFmhJ3sDCBwgpZUGXxjnqxBnE+
=puev
-----END PGP SIGNATURE-----