mirror of
https://github.com/nmap/nmap.git
synced 2026-02-05 04:56:34 +00:00
Address a few code analysis warnings: uninitialized vars and undefined behavior
This commit is contained in:
@@ -74,7 +74,7 @@ addr_cmp(const struct addr *a, const struct addr *b)
|
||||
if ((k = b->addr_bits % 8) == 0)
|
||||
return (0);
|
||||
|
||||
k = ~0 << (8 - k);
|
||||
k = (~(unsigned int)0) << (8 - k);
|
||||
i = b->addr_data8[j] & k;
|
||||
j = a->addr_data8[j] & k;
|
||||
|
||||
@@ -449,7 +449,7 @@ addr_btom(uint16_t bits, void *mask, size_t size)
|
||||
return (-1);
|
||||
}
|
||||
*(uint32_t *)mask = bits ?
|
||||
htonl(~0 << (IP_ADDR_BITS - bits)) : 0;
|
||||
htonl(~(uint32_t)0 << (IP_ADDR_BITS - bits)) : 0;
|
||||
} else {
|
||||
if (size * 8 < bits) {
|
||||
errno = EINVAL;
|
||||
|
||||
@@ -505,7 +505,7 @@ intf_loop(intf_t *intf, intf_handler callback, void *arg)
|
||||
IP_ADAPTER_ADDRESSES *a;
|
||||
struct intf_entry *entry;
|
||||
u_char ebuf[1024];
|
||||
int ret;
|
||||
int ret = 0;
|
||||
|
||||
if (_refresh_tables(intf) < 0)
|
||||
return (-1);
|
||||
|
||||
@@ -150,7 +150,7 @@ static void trie_free(struct trie_node *curr)
|
||||
/* Since we descend only down one side, we at most accumulate one tree's-depth, or 128.
|
||||
* Add 4 for safety to account for special root node and special empty stack position 0.
|
||||
*/
|
||||
struct trie_node *stack[128+4];
|
||||
struct trie_node *stack[128+4] = {NULL};
|
||||
int i = 1;
|
||||
|
||||
while (i > 0 && curr != NULL && curr != TRIE_NODE_TRUE) {
|
||||
|
||||
@@ -191,7 +191,7 @@ nsock_event_id nsock_printf(nsock_pool ms_pool, nsock_iod ms_iod,
|
||||
va_start(ap,format);
|
||||
res2 = Vsnprintf(buf2, buf2size, format, ap);
|
||||
va_end(ap);
|
||||
if (res2 < 0 || res2 >= buf2size) {
|
||||
if (res2 < 0 || (size_t) res2 >= buf2size) {
|
||||
free(buf2);
|
||||
buf2 = NULL;
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user