Fix compiler warnings from different compilers clang/gcc

This commit is contained in:
Peter Haag 2017-12-28 16:47:40 +01:00
parent 8a9dcb2bc8
commit 9c2e7d6f4a
9 changed files with 34 additions and 28 deletions

View File

@ -206,6 +206,9 @@ int i;
for (i=0; i<ancount && p < eod; i++ ) {
uint32_t type, class, ttl;
int32_t len = dn_expand(payload, eod, p, dn, DN_LENGTH);
// keep compiler happy
UNUSED(class);
UNUSED(ttl);
if(len < 0) {
LogError("dn_expand() failed: %s", "");
}

View File

@ -1322,6 +1322,8 @@ uint16_t offset_std_sampler_interval, offset_std_sampler_algorithm, found_std_sa
uint16_t id, length;
int Enterprise;
// keep compiler happy
UNUSED(enterprise_value);
id = Get_val16(DataPtr); DataPtr += 2;
length = Get_val16(DataPtr); DataPtr += 2;
size_left -= 4;

View File

@ -140,7 +140,7 @@ int verbose = 0;
static const char *nfdump_version = VERSION;
static int launcher_alive, periodic_trigger, launcher_pid;
static int launcher_pid;
static pthread_mutex_t m_done = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t terminate = PTHREAD_COND_INITIALIZER;
static pthread_key_t buffer_key;

View File

@ -61,7 +61,7 @@
enum { SRC_IP, DST_IP, UDP_PORT, TCP_PORT, ICMP_TYPE };
static pcap_t *pcap_handle;
static uint32_t tcp_count, udp_count, icmp_count, arp_count, unknow_count;
static uint32_t tcp_count, udp_count, arp_count, unknow_count;
/*
* Function prototypes

View File

@ -29,12 +29,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Author: haag $
*
* $Id: profile.c 41 2009-12-31 14:46:28Z haag $
*
* $LastChangedRevision: 41 $
*
*/
#include "config.h"
@ -357,7 +351,6 @@ void CloseChannels (time_t tslot, int compress) {
dirstat_t *dirstat;
struct stat fstat;
unsigned int num;
int ret, update_ok;
for ( num = 0; num < num_channels; num++ ) {
if ( profile_channels[num].ofile ) {
@ -368,10 +361,7 @@ int ret, update_ok;
profile_channels[num].nffile = DisposeFile(profile_channels[num].nffile);
stat(profile_channels[num].ofile, &fstat);
ret = ReadStatInfo(profile_channels[num].dirstat_path, &dirstat, CREATE_AND_LOCK);
update_ok = ret == STATFILE_OK;
ReadStatInfo(profile_channels[num].dirstat_path, &dirstat, CREATE_AND_LOCK);
if ( rename(profile_channels[num].ofile, profile_channels[num].wfile) < 0 ) {
LogError("Failed to rename file %s to %s: %s\n",

View File

@ -657,7 +657,6 @@ char *bindhost, *datadir, pidstr[32], *launch_process;
char *userid, *groupid, *checkptr, *listenport, *mcastgroup, *extension_tags;
char *Ident, *pcap_file, *time_extension, pidfile[MAXPATHLEN];
struct stat fstat;
srecord_t *commbuff;
packet_function_t receive_packet;
send_peer_t peer;
FlowSource_t *fs;
@ -1012,8 +1011,6 @@ int c;
exit(255);
}
commbuff = (srecord_t *)shmem;
launcher_pid = fork();
switch (launcher_pid) {
case 0:

View File

@ -547,6 +547,7 @@ typedef enum {
SFLAPP_NUM_STATUS_CODES
} EnumSFLAPPStatus;
#ifdef DEVEL
static const char *SFL_APP_STATUS_names[] = { "SUCCESS",
"OTHER",
"TIMEOUT",
@ -558,6 +559,7 @@ typedef enum {
"NOT_FOUND",
"UNAVAILABLE",
"UNATHORIZED" };
#endif
/* Operation context */
typedef struct {

View File

@ -64,18 +64,12 @@
#include <stdint.h>
#endif
// #include "sflow.h" /* sFlow v5 */
#include "sflow.h" /* sFlow v5 */
#include "sflow_v2v4.h" /* sFlow v2/4 */
#include "util.h"
#include "sflow_process.h"
#include "sflow_nfdump.h"
#ifndef DEVEL
# define dbg_printf(...) /* printf(__VA_ARGS__) */
#else
# define dbg_printf(...) printf(__VA_ARGS__)
#endif
static uint8_t bin2hex(int nib);
static int printHex(const uint8_t *a, int len, char *buf, int bufLen, int marker, int bytesPerOutputLine);
static char *IP_to_a(uint32_t ipaddr, char *buf, int buflen);
@ -1463,17 +1457,19 @@ static void readExtendedWifiRx(SFSample *sample)
static void readExtendedWifiTx(SFSample *sample)
{
#ifdef DEVEL
uint32_t i;
uint8_t *bssid;
char ssid[SFL_MAX_SSID_LEN+1];
if(getString(sample, ssid, SFL_MAX_SSID_LEN) > 0) {
dbg_printf("tx_SSID %s\n", ssid);
printf("tx_SSID %s\n", ssid);
}
bssid = (uint8_t *)sample->datap;
dbg_printf("tx_BSSID ");
printf("tx_BSSID ");
for(i = 0; i < 6; i++) dbg_printf("%02x", bssid[i]);
dbg_printf("\n");
printf("\n");
#endif
skipBytes(sample, 6);
sf_log_next32(sample, "tx_version");
@ -1754,6 +1750,12 @@ static void readFlowSample_http(SFSample *sample, uint32_t tag)
uint32_t status;
uint64_t resp_bytes;
// keep compiler happy
UNUSED(method);
UNUSED(protocol);
UNUSED(status);
UNUSED(resp_bytes);
dbg_printf("flowSampleType http\n");
method = sf_log_next32(sample, "http_method");
protocol = sf_log_next32(sample, "http_protocol");
@ -1931,6 +1933,9 @@ static void readExtendedProxySocket4(SFSample *sample)
char buf[51];
#endif
SFLAddress ipsrc,ipdst;
// keep compiler happy
UNUSED(ipsrc);
UNUSED(ipdst);
dbg_printf("extendedType proxy_socket4\n");
sf_log_next32(sample, "proxy_socket4_ip_protocol");
ipsrc.type = SFLADDRESSTYPE_IP_V4;
@ -2028,15 +2033,19 @@ static void readExtendedVNI(SFSample *sample, char *prefix)
static void readExtendedTCPInfo(SFSample *sample)
{
char *direction;
EnumPktDirection dirn = getData32(sample);
UNUSED(dirn); // keep compiler happy
#ifdef DEVEL
char *direction;
switch(dirn) {
case PKTDIR_unknown: direction = "unknown"; break;
case PKTDIR_received: direction = "received"; break;
case PKTDIR_sent: direction = "sent"; break;
default: direction = "<bad value>"; break;
}
dbg_printf( "tcpinfo_direction %s\n", direction);
printf( "tcpinfo_direction %s\n", direction);
#endif
sf_log_next32(sample, "tcpinfo_send_mss");
sf_log_next32(sample, "tcpinfo_receive_mss");
sf_log_next32(sample, "tcpinfo_unacked_pkts");

View File

@ -1,4 +1,5 @@
/*
* Copyright (c) 2017, Peter Haag
* Copyright (c) 2016, Peter Haag
* Copyright (c) 2014, Peter Haag
* Copyright (c) 2009, Peter Haag
@ -54,6 +55,8 @@
# define dbg_assert(a) /* assert(a) */
#endif
#define UNUSED(expr) do { (void)(expr); } while (0)
#define EBUFF_SIZE 256
#ifndef HAVE_HTONLL