From c2f583f0dacb6fe4792c133a00c7127a72246cc0 Mon Sep 17 00:00:00 2001 From: "Joseph C. Lehner" Date: Wed, 3 Feb 2016 17:32:15 +0200 Subject: [PATCH] #include cleanup --- ethsock.c | 11 ++++++----- nmrp.c | 7 ------- nmrpd.h | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ethsock.c b/ethsock.c index 2eb8a42..b85b79e 100644 --- a/ethsock.c +++ b/ethsock.c @@ -7,10 +7,9 @@ #include "nmrpd.h" #if defined(NMRPFLASH_WINDOWS) -#define NMRPFLASH_ALIAS_PREFIX "net" +#define NMRPFLASH_NETALIAS_PREFIX "net" #define WPCAP #include -#include #else #include #include @@ -151,7 +150,7 @@ static const char *intf_alias_to_wpcap(const char *intf) if (intf[0] == '\\') { return intf; - } else if (sscanf(intf, NMRPFLASH_ALIAS_PREFIX "%u", &dev_num) != 1) { + } else if (sscanf(intf, NMRPFLASH_NETALIAS_PREFIX "%u", &dev_num) != 1) { fprintf(stderr, "Invalid interface alias.\n"); return NULL; } @@ -162,7 +161,9 @@ static const char *intf_alias_to_wpcap(const char *intf) for (dev = devs; dev; dev = dev->next) { if (i == dev_num) { - printf(NMRPFLASH_ALIAS_PREFIX "%u: %s\n", i, dev->name); + if (verbosity) { + printf("%s%u: %s\n", NMRPFLASH_NETALIAS_PREFIX, i, dev->name); + } strncpy(buf, dev->name, sizeof(buf) - 1); buf[sizeof(buf) - 1] = '\0'; break; @@ -332,7 +333,7 @@ ssize_t ethsock_recv(struct ethsock *sock, void *buf, size_t len) if (ret == WAIT_TIMEOUT) { return 0; } else if (ret != WAIT_OBJECT_0) { - fprintf(stderr, "WaitForSingleObject: returned %d\n", (int)ret); + win_perror("WaitForSingleObject", ret); return -1; } } diff --git a/nmrp.c b/nmrp.c index bdbb6fe..288bbb7 100644 --- a/nmrp.c +++ b/nmrp.c @@ -17,7 +17,6 @@ * */ -#define _BSD_SOURCE #include #include #include @@ -28,12 +27,6 @@ #include "ethsock.h" #include "nmrpd.h" -#ifndef NMRPFLASH_WINDOWS -#include -#else -#include -#endif - #define NMRP_HDR_LEN 6 #define NMRP_OPT_LEN 4 #define NMRP_MIN_PKT_LEN (sizeof(struct eth_hdr) + NMRP_HDR_LEN) diff --git a/nmrpd.h b/nmrpd.h index 25d9e5f..71d37c4 100644 --- a/nmrpd.h +++ b/nmrpd.h @@ -34,7 +34,6 @@ #endif #ifndef NMRPFLASH_WINDOWS -#define _BSD_SOURCE #include #include #include @@ -42,6 +41,7 @@ #include #include #include +#include #endif #define NMRPD_VERSION "0.9" -- 2.25.1