From 5cd6c38893bff6efb7921650208a4f27611105b3 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 20 Nov 2017 12:02:20 +0800 Subject: [PATCH] apps/snmp: Fix buld error when LWIP_SNMP_CONFIGURE_VERSIONS=1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: goldsimon --- src/apps/snmp/snmp_msg.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/apps/snmp/snmp_msg.c b/src/apps/snmp/snmp_msg.c index 6a3fbf16..29cb0413 100644 --- a/src/apps/snmp/snmp_msg.c +++ b/src/apps/snmp/snmp_msg.c @@ -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