apps/snmp: Fix buld error when LWIP_SNMP_CONFIGURE_VERSIONS=1

The version check is done in these functions, it should be ok to put
assert in the else clause.

Fix below build errors:

../../../../lwip/src/apps/snmp/snmp_msg.c: In function ‘snmp_version_enabled’:
../../../../lwip/src/apps/snmp/snmp_msg.c:87:1: error: embedding a directive within macro arguments is not portable [-Werror]
 #if LWIP_SNMP_V3
 ^
../../../../lwip/src/apps/snmp/snmp_msg.c:89:1: error: embedding a directive within macro arguments is not portable [-Werror]
 #endif
 ^
../../../../lwip/src/apps/snmp/snmp_msg.c: In function ‘snmp_version_enable’:
../../../../lwip/src/apps/snmp/snmp_msg.c:126:1: error: embedding a directive within macro arguments is not portable [-Werror]
 #if LWIP_SNMP_V3
 ^
../../../../lwip/src/apps/snmp/snmp_msg.c:128:1: error: embedding a directive within macro arguments is not portable [-Werror]
 #endif
 ^
cc1: all warnings being treated as errors
/home/axel/git/lwip/lwip-contrib/ports/unix/../Common.allports.mk:94:
recipe for target 'snmp_msg.o' failed
make: *** [snmp_msg.o] Error 1

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
Axel Lin 2017-11-20 12:02:20 +08:00 committed by goldsimon
parent b48106c662
commit 5cd6c38893

View File

@ -83,22 +83,20 @@ static u8_t v3_enabled = 1;
static u8_t
snmp_version_enabled(u8_t version)
{
LWIP_ASSERT("Invalid SNMP version", (version == SNMP_VERSION_1) || (version == SNMP_VERSION_2c)
#if LWIP_SNMP_V3
|| (version == SNMP_VERSION_3)
#endif
);
if (version == SNMP_VERSION_1) {
return v1_enabled;
} else if (version == SNMP_VERSION_2c) {
return v2c_enabled;
}
#if LWIP_SNMP_V3
else { /* version == SNMP_VERSION_3 */
else if (version == SNMP_VERSION_3) {
return v3_enabled;
}
#endif
else {
LWIP_ASSERT("Invalid SNMP version", 0);
return 0;
}
}
u8_t
@ -122,22 +120,19 @@ snmp_v3_enabled(void)
static void
snmp_version_enable(u8_t version, u8_t enable)
{
LWIP_ASSERT("Invalid SNMP version", (version == SNMP_VERSION_1) || (version == SNMP_VERSION_2c)
#if LWIP_SNMP_V3
|| (version == SNMP_VERSION_3)
#endif
);
if (version == SNMP_VERSION_1) {
v1_enabled = enable;
} else if (version == SNMP_VERSION_2c) {
v2c_enabled = enable;
}
#if LWIP_SNMP_V3
else { /* version == SNMP_VERSION_3 */
else if (version == SNMP_VERSION_3) {
v3_enabled = enable;
}
#endif
else {
LWIP_ASSERT("Invalid SNMP version", 0);
}
}
void