From 401a2e98af356f2a0e07db6caae987a49ae1270c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sat, 6 Feb 2016 14:23:28 +0100 Subject: [PATCH] Error in iteractive algorithm, continue statement, continue for and not global while --- src/ip_to_geo.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ip_to_geo.c b/src/ip_to_geo.c index 506697f..a009e1b 100644 --- a/src/ip_to_geo.c +++ b/src/ip_to_geo.c @@ -12,12 +12,13 @@ static const uint8_t* ip_to_geo_rec(uint8_t* ip, unsigned level, const ip_level* root) { - unsigned cur_average; + uint8_t cur_average; const ip_level* cur_ip; - unsigned cur_addr; + uint8_t cur_addr; while (1) { + start_loop: cur_ip = root; cur_addr = ip[level]; @@ -38,7 +39,7 @@ static const uint8_t* ip_to_geo_rec(uint8_t* ip, unsigned level, const ip_level* { \ level++; \ root = cur_ip->childs; \ - continue; \ + goto start_loop; \ } \ else \ return &cur_ip->code; \ @@ -105,7 +106,7 @@ int interactive(struct gengetopt_args_info* params) } } - cc = ip_to_geo((uint8_t*)&ret, ip_size); + cc = ip_to_geo(ip, ip_size); if (params->quiet_flag) printf("%s\n", (cc)?(char*)get_country_code(cc):"");