Fixes for type-punned pointers - Henne Vogelsang <hvogel@suse.de>
This commit is contained in:
6
iftop.c
6
iftop.c
@@ -187,6 +187,10 @@ static void handle_ip_packet(struct ip* iptr, int hw_dir)
|
||||
{
|
||||
int direction = 0; /* incoming */
|
||||
history_type* ht;
|
||||
union {
|
||||
history_type **ht_pp;
|
||||
void **void_pp;
|
||||
} u_ht = { &ht };
|
||||
addr_pair ap;
|
||||
int len;
|
||||
|
||||
@@ -261,7 +265,7 @@ static void handle_ip_packet(struct ip* iptr, int hw_dir)
|
||||
resolve(&iptr->ip_dst, NULL, 0);
|
||||
resolve(&iptr->ip_src, NULL, 0);
|
||||
|
||||
if(hash_find(history, &ap, (void**)&ht) == HASH_STATUS_KEY_NOT_FOUND) {
|
||||
if(hash_find(history, &ap, u_ht.void_pp) == HASH_STATUS_KEY_NOT_FOUND) {
|
||||
ht = history_create();
|
||||
hash_insert(history, &ap, ht);
|
||||
}
|
||||
|
||||
12
resolver.c
12
resolver.c
@@ -392,7 +392,11 @@ void resolver_worker(void* ptr) {
|
||||
|
||||
if(hostname != NULL) {
|
||||
char* old;
|
||||
if(hash_find(ns_hash, &addr, (void**)&old) == HASH_STATUS_OK) {
|
||||
union {
|
||||
char **ch_pp;
|
||||
void **void_pp;
|
||||
} u_old = { &old };
|
||||
if(hash_find(ns_hash, &addr, u_old.void_pp) == HASH_STATUS_OK) {
|
||||
hash_delete(ns_hash, &addr);
|
||||
xfree(old);
|
||||
}
|
||||
@@ -424,13 +428,17 @@ void resolver_initialise() {
|
||||
|
||||
void resolve(struct in_addr* addr, char* result, int buflen) {
|
||||
char* hostname;
|
||||
union {
|
||||
char **ch_pp;
|
||||
void **void_pp;
|
||||
} u_hostname = { &hostname };
|
||||
int added = 0;
|
||||
|
||||
if(options.dnsresolution == 1) {
|
||||
|
||||
pthread_mutex_lock(&resolver_queue_mutex);
|
||||
|
||||
if(hash_find(ns_hash, addr, (void**)&hostname) == HASH_STATUS_OK) {
|
||||
if(hash_find(ns_hash, addr, u_hostname.void_pp) == HASH_STATUS_OK) {
|
||||
/* Found => already resolved, or on the queue */
|
||||
}
|
||||
else {
|
||||
|
||||
13
ui.c
13
ui.c
@@ -472,6 +472,10 @@ void analyse_data() {
|
||||
while(hash_next_item(history, &n) == HASH_STATUS_OK) {
|
||||
history_type* d = (history_type*)n->rec;
|
||||
host_pair_line* screen_line;
|
||||
union {
|
||||
host_pair_line **h_p_l_pp;
|
||||
void **void_pp;
|
||||
} u_screen_line = { &screen_line };
|
||||
addr_pair ap;
|
||||
int i;
|
||||
int tsent, trecv;
|
||||
@@ -500,7 +504,7 @@ void analyse_data() {
|
||||
}
|
||||
|
||||
|
||||
if(hash_find(screen_hash, &ap, (void**)&screen_line) == HASH_STATUS_KEY_NOT_FOUND) {
|
||||
if(hash_find(screen_hash, &ap, u_screen_line.void_pp) == HASH_STATUS_KEY_NOT_FOUND) {
|
||||
screen_line = xcalloc(1, sizeof *screen_line);
|
||||
hash_insert(screen_hash, &ap, screen_line);
|
||||
screen_line->ap = ap;
|
||||
@@ -534,6 +538,11 @@ void sprint_host(char * line, struct in_addr* addr, unsigned int port, unsigned
|
||||
char hostname[HOSTNAME_LENGTH];
|
||||
char service[HOSTNAME_LENGTH];
|
||||
char* s_name;
|
||||
union {
|
||||
char **ch_pp;
|
||||
void **void_pp;
|
||||
} u_s_name = { &s_name };
|
||||
|
||||
ip_service skey;
|
||||
int left;
|
||||
if(addr->s_addr == 0) {
|
||||
@@ -550,7 +559,7 @@ void sprint_host(char * line, struct in_addr* addr, unsigned int port, unsigned
|
||||
if(port != 0) {
|
||||
skey.port = port;
|
||||
skey.protocol = protocol;
|
||||
if(options.portresolution && hash_find(service_hash, &skey, (void**)&s_name) == HASH_STATUS_OK) {
|
||||
if(options.portresolution && hash_find(service_hash, &skey, u_s_name.void_pp) == HASH_STATUS_OK) {
|
||||
snprintf(service, HOSTNAME_LENGTH, ":%s", s_name);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user