bug: use uint32_t for IP numbers

The commit 1e82461875 was
incomplete, and at the end was a cause of off by one miscount.
The reason was bsearch where long int needed to be unsigned.
Weird that the original had work while there where so many type
mismatches.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2011-07-09 23:32:25 +02:00
parent f51f2e9fe1
commit f9eb53a215
2 changed files with 8 additions and 8 deletions

View file

@ -64,7 +64,7 @@ int prepare_data(void)
for (i = 0; i < num_touches; i++) {
if (bsearch
(&touches[i], leases, (size_t) num_leases,
sizeof(long int), &intcomp) == NULL) {
sizeof(uint32_t), &intcomp) == NULL) {
touches[j] = touches[i];
j++;
}

View file

@ -113,14 +113,14 @@ int parse_leases(void)
leasesmallocsize = (lease_file_stats.st_size / 250) + MAXLEN - 2;
touchesmallocsize = (lease_file_stats.st_size / 250) + MAXLEN - 2;
backupsmallocsize = (lease_file_stats.st_size / 120) + MAXLEN - 2;
leases = safe_malloc(sizeof(long int) * leasesmallocsize);
touches = safe_malloc((size_t) sizeof(long int) * touchesmallocsize);
leases = safe_malloc(sizeof(uint32_t) * leasesmallocsize);
touches = safe_malloc(sizeof(uint32_t) * touchesmallocsize);
memset(leases, 0, sizeof(long int) * leasesmallocsize);
memset(touches, 0, sizeof(long int) * touchesmallocsize);
memset(leases, 0, sizeof(uint32_t) * leasesmallocsize);
memset(touches, 0, sizeof(uint32_t) * touchesmallocsize);
line = safe_malloc(sizeof(long int) * MAXLEN);
ipstring = safe_malloc(sizeof(long int) * MAXLEN);
line = safe_malloc(sizeof(char) * MAXLEN);
ipstring = safe_malloc(sizeof(char) * MAXLEN);
if (config.output_format[0] == 'X') {
macstring = safe_malloc(sizeof(char) * 18);
macaddr = safe_malloc(sizeof(struct macaddr_t));
@ -164,7 +164,7 @@ int parse_leases(void)
} else if (strstr(line, " binding state backup")) {
if (num_backups == 0) {
backups =
safe_malloc((size_t) sizeof(long int) *
safe_malloc(sizeof(uint32_t) *
backupsmallocsize);
}
backups[num_backups] = htonl(inp.s_addr);