From 6dcb2b2415cd65fbe256f9521875374e9b433f8f Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Fri, 12 Aug 2016 22:51:43 +0200 Subject: [PATCH] Work on bug #48730: Enums should be used instead of multiple defines (where applicable) --- src/core/dns.c | 10 +++++---- src/include/lwip/err.h | 48 ++++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/core/dns.c b/src/core/dns.c index 9aed4733..07c330cc 100644 --- a/src/core/dns.c +++ b/src/core/dns.c @@ -205,10 +205,12 @@ static u16_t dns_txid; #define DNS_FLAG2_ERR_NAME 0x03 /* DNS protocol states */ -#define DNS_STATE_UNUSED 0 -#define DNS_STATE_NEW 1 -#define DNS_STATE_ASKING 2 -#define DNS_STATE_DONE 3 +typedef enum { + DNS_STATE_UNUSED = 0, + DNS_STATE_NEW = 1, + DNS_STATE_ASKING = 2, + DNS_STATE_DONE = 3 +} dns_state_enum_t; #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" diff --git a/src/include/lwip/err.h b/src/include/lwip/err.h index 81a049d8..565a7311 100644 --- a/src/include/lwip/err.h +++ b/src/include/lwip/err.h @@ -57,44 +57,46 @@ typedef LWIP_ERR_T err_t; typedef s8_t err_t; #endif /* LWIP_ERR_T*/ -/* Definitions for error constants. */ - +/** Definitions for error constants. */ +typedef enum { /** No error, everything OK. */ -#define ERR_OK 0 + ERR_OK = 0, /** Out of memory error. */ -#define ERR_MEM -1 + ERR_MEM = -1, /** Buffer error. */ -#define ERR_BUF -2 + ERR_BUF = -2, /** Timeout. */ -#define ERR_TIMEOUT -3 + ERR_TIMEOUT = -3, /** Routing problem. */ -#define ERR_RTE -4 + ERR_RTE = -4, /** Operation in progress */ -#define ERR_INPROGRESS -5 + ERR_INPROGRESS = -5, /** Illegal value. */ -#define ERR_VAL -6 + ERR_VAL = -6, /** Operation would block. */ -#define ERR_WOULDBLOCK -7 + ERR_WOULDBLOCK = -7, /** Address in use. */ -#define ERR_USE -8 + ERR_USE = -8, /** Already connecting. */ -#define ERR_ALREADY -9 + ERR_ALREADY = -9, /** Conn already established.*/ -#define ERR_ISCONN -10 + ERR_ISCONN = -10, /** Not connected. */ -#define ERR_CONN -11 + ERR_CONN = -11, /** Low-level netif error */ -#define ERR_IF -12 + ERR_IF = -12, + +/** Connection aborted. */ + ERR_ABRT = -13, +/** Connection reset. */ + ERR_RST = -14, +/** Connection closed. */ + ERR_CLSD = -15, +/** Illegal argument. */ + ERR_ARG = -16 +} err_enum_t; #define ERR_IS_FATAL(e) ((e) <= ERR_ABRT) -/** Connection aborted. */ -#define ERR_ABRT -13 -/** Connection reset. */ -#define ERR_RST -14 -/** Connection closed. */ -#define ERR_CLSD -15 -/** Illegal argument. */ -#define ERR_ARG -16 /** * @}