From 4fb433ac1ffc2dbb36e6964b8c2f8bcc68615ace Mon Sep 17 00:00:00 2001 From: Salvatore Pitrulli Date: Thu, 12 May 2011 21:50:47 +0200 Subject: [PATCH] 'if' statement replaced by a preprocessor directive. --- core/net/mac/contikimac.c | 56 +++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/core/net/mac/contikimac.c b/core/net/mac/contikimac.c index 82c027b07..af4fce07e 100644 --- a/core/net/mac/contikimac.c +++ b/core/net/mac/contikimac.c @@ -633,35 +633,35 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr) } packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1); - if(WITH_CONTIKIMAC_HEADER) { - hdrlen = packetbuf_totlen(); - if(packetbuf_hdralloc(sizeof(struct hdr)) == 0) { - /* Failed to allocate space for contikimac header */ - PRINTF("contikimac: send failed, too large header\n"); - return MAC_TX_ERR_FATAL; - } - chdr = packetbuf_hdrptr(); - chdr->id = CONTIKIMAC_ID; - chdr->len = hdrlen; - - /* Create the MAC header for the data packet. */ - hdrlen = NETSTACK_FRAMER.create(); - if(hdrlen == 0) { - /* Failed to send */ - PRINTF("contikimac: send failed, too large header\n"); - packetbuf_hdr_remove(sizeof(struct hdr)); - return MAC_TX_ERR_FATAL; - } - hdrlen += sizeof(struct hdr); - } else { - /* Create the MAC header for the data packet. */ - hdrlen = NETSTACK_FRAMER.create(); - if(hdrlen == 0) { - /* Failed to send */ - PRINTF("contikimac: send failed, too large header\n"); - return MAC_TX_ERR_FATAL; - } +#if WITH_CONTIKIMAC_HEADER + hdrlen = packetbuf_totlen(); + if(packetbuf_hdralloc(sizeof(struct hdr)) == 0) { + /* Failed to allocate space for contikimac header */ + PRINTF("contikimac: send failed, too large header\n"); + return MAC_TX_ERR_FATAL; } + chdr = packetbuf_hdrptr(); + chdr->id = CONTIKIMAC_ID; + chdr->len = hdrlen; + + /* Create the MAC header for the data packet. */ + hdrlen = NETSTACK_FRAMER.create(); + if(hdrlen == 0) { + /* Failed to send */ + PRINTF("contikimac: send failed, too large header\n"); + packetbuf_hdr_remove(sizeof(struct hdr)); + return MAC_TX_ERR_FATAL; + } + hdrlen += sizeof(struct hdr); +#else + /* Create the MAC header for the data packet. */ + hdrlen = NETSTACK_FRAMER.create(); + if(hdrlen == 0) { + /* Failed to send */ + PRINTF("contikimac: send failed, too large header\n"); + return MAC_TX_ERR_FATAL; + } +#endif /* Make sure that the packet is longer or equal to the shortest