Commit 836733ba by pdw

Fixes for a bunch of compiler warnings.

1 parent a7b8639f
......@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "addr_hash.h"
#include "hash.h"
#include "iftop.h"
......
......@@ -90,28 +90,23 @@ get_addrs_ioctl(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr,
sysctlparam[5] = if_nametoindex(interface);
if (sysctlparam[5] == 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
}
if (sysctl(sysctlparam, 6, NULL, &needed, NULL, 0) < 0) {
else if (sysctl(sysctlparam, 6, NULL, &needed, NULL, 0) < 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
}
if ((buf = malloc(needed)) == NULL) {
else if ((buf = malloc(needed)) == NULL) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
}
if (sysctl(sysctlparam, 6, buf, &needed, NULL, 0) < 0) {
else if (sysctl(sysctlparam, 6, buf, &needed, NULL, 0) < 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
free(buf);
goto ENDHWADDR;
}
msghdr = (struct if_msghdr *) buf;
memcpy(if_hw_addr, LLADDR((struct sockaddr_dl *)(buf + sizeof(struct if_msghdr) - sizeof(struct if_data) + sizeof(struct if_data))), 6);
free(buf);
got_hw_addr = 1;
ENDHWADDR:
1; /* compiler whines if there is a label at the end of a block...*/
else {
msghdr = (struct if_msghdr *) buf;
memcpy(if_hw_addr, LLADDR((struct sockaddr_dl *)(buf + sizeof(struct if_msghdr) - sizeof(struct if_data) + sizeof(struct if_data))), 6);
free(buf);
got_hw_addr = 1;
}
}
#else
fprintf(stderr, "Cannot obtain hardware address on this platform\n");
......
......@@ -8,6 +8,7 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "stringmap.h"
#include "iftop.h"
......@@ -169,7 +170,6 @@ int config_get_int(const char *directive, int *value) {
* failure, or 0 if no value was found. */
int config_get_float(const char *directive, float *value) {
stringmap S;
item *I;
char *s, *t;
if (!value) return -1;
......@@ -245,7 +245,5 @@ void config_set_string(const char *directive, const char* s) {
}
int read_config(char *file, int whinge_on_error) {
void* o;
return read_config_file(file, whinge_on_error);
}
......@@ -20,6 +20,8 @@ int config_get_bool(const char *directive);
int config_get_int(const char *directive, int *value);
int config_get_float(const char *directive, float *value);
int config_init();
void config_set_string(const char *directive, const char* s);
int config_get_enum(const char *directive, config_enumeration_type *enumeration, int *value);
......
......@@ -49,12 +49,13 @@
#include "ethertype.h"
#include "cfgfile.h"
#include "ppp.h"
#include "addrs_ioctl.h"
#include <netinet/ip6.h>
/* ethernet address of interface. */
int have_hw_addr = 0;
unsigned char if_hw_addr[6];
char if_hw_addr[6];
/* IP address of interface */
int have_ip_addr = 0;
......@@ -498,9 +499,9 @@ static void handle_llc_packet(const struct llc* llc, int dir) {
if(llc->ssap == LLCSAP_SNAP && llc->dsap == LLCSAP_SNAP
&& llc->llcui == LLC_UI) {
u_int32_t orgcode;
register u_short et;
u_int16_t et;
orgcode = EXTRACT_24BITS(&llc->llc_orgcode[0]);
et = EXTRACT_16BITS(&llc->llc_ethertype[0]);
et = (llc->llc_ethertype[0] << 8) + llc->llc_ethertype[1];
switch(orgcode) {
case OUI_ENCAP_ETHER:
case OUI_CISCO_90:
......@@ -679,7 +680,6 @@ char *set_filter_code(const char *filter) {
void packet_init() {
char errbuf[PCAP_ERRBUF_SIZE];
char *m;
int s;
int i;
int dlt;
int result;
......
......@@ -173,79 +173,6 @@ void options_set_defaults() {
}
static void die(char *msg) {
fprintf(stderr, "%s", msg);
exit(1);
}
static void set_max_bandwidth(char* arg) {
char* units;
long long mult = 1;
long long value;
units = arg + strspn(arg, "0123456789");
if(strlen(units) > 1) {
die("Invalid units\n");
}
if(strlen(units) == 1) {
if(*units == 'k' || *units == 'K') {
mult = 1024;
}
else if(*units == 'm' || *units == 'M') {
mult = 1024 * 1024;
}
else if(*units == 'g' || *units == 'G') {
mult = 1024 * 1024 * 1024;
}
}
*units = '\0';
if(sscanf(arg, "%lld", &value) != 1) {
die("Error reading max bandwidth\n");
}
options.max_bandwidth = value * mult;
}
static void set_net_filter(char* arg) {
char* mask;
mask = strchr(arg, '/');
if (mask == NULL) {
die("Could not parse net/mask\n");
}
*mask = '\0';
mask++;
if (inet_aton(arg, &options.netfilternet) == 0)
die("Invalid network address\n");
/* Accept a netmask like /24 or /255.255.255.0. */
if (mask[strspn(mask, "0123456789")] == '\0') {
/* Whole string is numeric */
int n;
n = atoi(mask);
if (n > 32) {
die("Invalid netmask");
}
else {
if(n == 32) {
/* This needs to be special cased, although I don't fully
* understand why -pdw
*/
options.netfiltermask.s_addr = htonl(0xffffffffl);
}
else {
u_int32_t mm = 0xffffffffl;
mm >>= n;
options.netfiltermask.s_addr = htonl(~mm);
}
}
}
else if (inet_aton(mask, &options.netfiltermask) == 0) {
die("Invalid netmask\n");
}
options.netfilternet.s_addr = options.netfilternet.s_addr & options.netfiltermask.s_addr;
options.netfilter = 1;
}
/* usage:
* Print usage information. */
static void usage(FILE *fp) {
......
......@@ -96,5 +96,7 @@ typedef struct {
void options_set_defaults();
void options_read(int argc, char **argv);
void options_read_args(int argc, char **argv);
void options_make();
#endif /* __OPTIONS_H_ */
......@@ -13,6 +13,7 @@
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#if defined(HAVE_TERMIOS_H)
......
......@@ -177,7 +177,7 @@ static void draw_bar_scale(int* y) {
void draw_line_total(float sent, float recv, int y, int x, option_linedisplay_t linedisplay, int bytes) {
char buf[10];
float n;
float n = 0;
switch(linedisplay) {
case OPTION_LINEDISPLAY_TWO_LINE:
draw_line_total(sent, recv, y, x, OPTION_LINEDISPLAY_ONE_LINE_SENT, bytes);
......
......@@ -6,6 +6,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "addr_hash.h"
#include "serv_hash.h"
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!