diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2016-02-17 11:45:49 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2016-02-18 12:16:18 +0200 |
commit | 53dbe52f7dea31e5f160d6965a07a54f6d43a634 (patch) | |
tree | 2e75cc49adad6d1418898b3beec5ab4dcf50e214 | |
parent | c22f55194002d796ed590d2109810d36f4ab8a7b (diff) |
net: echo_server: Avoid using #ifdef and #ifndef
It is prefered to use #if (!)defined form for checking defines since it
can actually check more complex conditions.
Change-Id: I59c6fff1f2d4e950f9ae64adb9f8833ef0fea4d0
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
-rw-r--r-- | samples/net/echo_server/src/echo-server.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/samples/net/echo_server/src/echo-server.c b/samples/net/echo_server/src/echo-server.c index d88771115..4cbf947b4 100644 --- a/samples/net/echo_server/src/echo-server.c +++ b/samples/net/echo_server/src/echo-server.c @@ -35,7 +35,7 @@ #include <contiki/ip/uip.h> #include <contiki/ipv6/uip-ds6.h> -#ifndef CONFIG_ETHERNET +#if !defined(CONFIG_ETHERNET) /* The peer is the client in our case. Just invent a mac * address for it because lower parts of the stack cannot set it * in this test as we do not have any radios. @@ -47,7 +47,7 @@ static uint8_t peer_mac[] = { 0x15, 0x0a, 0xbe, 0xef, 0xf0, 0x0d }; static uint8_t my_mac[] = { 0x0a, 0xbe, 0xef, 0x15, 0xf0, 0x0d }; #endif -#ifdef CONFIG_NETWORKING_WITH_IPV6 +#if defined(CONFIG_NETWORKING_WITH_IPV6) /* The 2001:db8::/32 is the private address space for documentation RFC 3849 */ #define MY_IPADDR { { { 0x20,0x01,0x0d,0xb8,0,0,0,0,0,0,0,0,0,0,0,0x1 } } } #define PEER_IPADDR { { { 0x20,0x01,0x0d,0xb8,0,0,0,0,0,0,0,0,0,0,0,0x2 } } } @@ -70,11 +70,11 @@ static inline void init_server() { PRINT("%s: run echo server\n", __func__); -#ifndef CONFIG_ETHERNET +#if !defined(CONFIG_ETHERNET) net_set_mac(my_mac, sizeof(my_mac)); #endif -#ifdef CONFIG_NETWORKING_WITH_IPV4 +#if defined(CONFIG_NETWORKING_WITH_IPV4) { uip_ipaddr_t addr; uip_ipaddr(&addr, 192,0,2,2); @@ -84,7 +84,7 @@ static inline void init_server() { uip_ipaddr_t *addr; -#ifdef CONFIG_NETWORKING_IPV6_NO_ND +#if defined(CONFIG_NETWORKING_IPV6_NO_ND) /* Set the routes and neighbor cache only if we do not have * neighbor discovery enabled. This setting should only be * used if running in qemu and using slip (tun device). @@ -138,7 +138,7 @@ static inline struct net_buf *prepare_reply(const char *name, */ reverse(ip_buf_appdata(buf), ip_buf_appdatalen(buf)); -#ifndef CONFIG_ETHERNET +#if !defined(CONFIG_ETHERNET) /* Set the mac address of the peer in net_buf because * there is no radio layer involved in this test app. * Normally there is no need to do this. @@ -190,7 +190,7 @@ static inline bool get_context(struct net_context **recv, static struct net_addr any_addr; static struct net_addr my_addr; -#ifdef CONFIG_NETWORKING_WITH_IPV6 +#if defined(CONFIG_NETWORKING_WITH_IPV6) static const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; static const struct in6_addr in6addr_mcast = MCAST_IPADDR; @@ -237,7 +237,7 @@ static inline bool get_context(struct net_context **recv, return true; } -#ifdef CONFIG_NANOKERNEL +#if defined(CONFIG_NANOKERNEL) #define STACKSIZE 2000 char __noinit __stack fiberStack[STACKSIZE]; #endif @@ -263,7 +263,7 @@ void main(void) init_server(); -#ifdef CONFIG_MICROKERNEL +#if defined(CONFIG_MICROKERNEL) receive(); #else task_fiber_start (&fiberStack[0], STACKSIZE, |