lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] Code cleanups for 1.4.0


From: Kieran Mansley
Subject: [lwip-devel] Code cleanups for 1.4.0
Date: Mon, 28 Jun 2010 14:43:59 +0100

I'm cleaning up some of the code and checking that things still compile
on unix before preparing the first release candidate for 1.4.0.

One set of errors that my compiler is throwing up is things like this:

   ../../../../../lwip/src/core/snmp/msg_in.c: In function
‘snmp_pdu_dec_varbindlist’:
../../../../../lwip/src/core/snmp/msg_in.c:1188: warning: suggest
parentheses around operand of ‘!’ or change ‘|’ to ‘||’ or ‘!’ to ‘~’

Having had a look at the code I have to agree with the compiler.  It's
complaining about mixing of logical and bitwise operators, e.g. we have
things like this:

#define SNMP_ASN1_UNIV   (!0x80 | !0x40)
#define SNMP_ASN1_APPLIC (!0x80 |  0x40)
#define SNMP_ASN1_CONTXT ( 0x80 | !0x40)

#define SNMP_ASN1_CONSTR (0x20)
#define SNMP_ASN1_PRIMIT (!0x20)


switch(type) {
 ...
 case (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER):
 ...
}

What do the "!" in the defines signify in this context?  My guess is the
writer was trying to express something like "type != 0x80 || type ==
0x40" (for SNMP_ASN1_APPLIC) but that seems like an odd thing to want to
write.

I appreciate that this code hasn't changed recently, but I'm not sure
why I haven't noticed it before.

Can anyone offer a clue about what this code is trying to do, and how we
could express it in a more logical fashion?

Thanks

Kieran




reply via email to

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