From: Christian Grothoff Date: Sun, 11 Mar 2012 22:48:04 +0000 (+0000) Subject: -LRN: use plibc SSCANF instead of sscanf X-Git-Tag: initial-import-from-subversion-38251~14294 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e1ff0291a39991e4ce025ece424ca8fae82fd88b;p=oweals%2Fgnunet.git -LRN: use plibc SSCANF instead of sscanf --- diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index 386ea5f29..6165a9db2 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c @@ -1127,7 +1127,7 @@ run (void *cls, char *const *args, const char *cfgfile, "connect_topology_option_modifier", &connect_topology_option_modifier_string)) { - if (sscanf + if (SSCANF (connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1) { diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 43cf2c5bd..db9b7d166 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c @@ -214,7 +214,7 @@ percent_decode_keyword (const char *in, char **emsg) { if (out[rpos] == '%') { - if (1 != sscanf (&out[rpos + 1], "%2X", &hx)) + if (1 != SSCANF (&out[rpos + 1], "%2X", &hx)) { GNUNET_free (out); *emsg = GNUNET_strdup (_("`%' must be followed by HEX number")); diff --git a/src/nat/gnunet-helper-nat-client.c b/src/nat/gnunet-helper-nat-client.c index 73504ab1d..cc51fb575 100644 --- a/src/nat/gnunet-helper-nat-client.c +++ b/src/nat/gnunet-helper-nat-client.c @@ -473,7 +473,7 @@ main (int argc, char *const *argv) global_ret = 7; goto cleanup; } - if ((1 != sscanf (argv[3], "%u", &p)) || (0 == p) || (0xFFFF < p)) + if ((1 != SSCANF (argv[3], "%u", &p)) || (0 == p) || (0xFFFF < p)) { fprintf (stderr, "Error parsing port value `%s'\n", argv[3]); global_ret = 8; diff --git a/src/nat/nat.c b/src/nat/nat.c index 725bbe952..53301ebb1 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c @@ -795,7 +795,7 @@ nat_server_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #if HAVE_SOCKADDR_IN_SIN_LEN sin_addr.sin_len = sizeof (sin_addr); #endif - if ((NULL == port_start) || (1 != sscanf (port_start, "%d", &port)) || + if ((NULL == port_start) || (1 != SSCANF (port_start, "%d", &port)) || (-1 == inet_pton (AF_INET, mybuf, &sin_addr.sin_addr))) { /* should we restart gnunet-helper-nat-server? */ diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index 830fdfd50..84cc84186 100644 --- a/src/nat/nat_mini.c +++ b/src/nat/nat_mini.c @@ -378,7 +378,7 @@ process_refresh_output (void *cls, const char *line) if (NULL == strstr (s, pstr)) return; /* skip */ if (1 != - sscanf (line, + SSCANF (line, (mini->is_tcp) ? "%*u TCP %u->%*s:%*u %*s" : "%*u UDP %u->%*s:%*u %*s", &nport)) return; /* skip */ @@ -446,7 +446,7 @@ process_map_output (void *cls, const char *line) */ if ((NULL == (ipaddr = strstr (line, " "))) || (NULL == (pstr = strstr (ipaddr, ":"))) || - (1 != sscanf (pstr + 1, "%u", &port))) + (1 != SSCANF (pstr + 1, "%u", &port))) { return; /* skip line */ } diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c index e300f95e3..b06655ca4 100644 --- a/src/testing/test_testing_group_remote.c +++ b/src/testing/test_testing_group_remote.c @@ -171,7 +171,7 @@ run (void *cls, char *const *args, const char *cfgfile, data[count] = '\0'; temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); ret = - sscanf (buf, "%a[a-zA-Z0-9]@%a[a-zA-Z0-9.]:%hd", + SSCANF (buf, "%a[a-zA-Z0-9]@%a[a-zA-Z0-9.]:%hd", &temphost->username, &temphost->hostname, &temphost->port); if (3 == ret) { diff --git a/src/testing/test_testing_large_topology.c b/src/testing/test_testing_large_topology.c index 605761105..ad6d973d2 100644 --- a/src/testing/test_testing_large_topology.c +++ b/src/testing/test_testing_large_topology.c @@ -1012,7 +1012,7 @@ run (void *cls, char *const *args, const char *cfgfile, "connect_topology_option_modifier", &connect_topology_option_modifier_string)) { - if (sscanf + if (SSCANF (connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1) { diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index ba5e23791..112838f2f 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -1069,7 +1069,7 @@ run (void *cls, char *const *args, const char *cfgfile, "connect_topology_option_modifier", &connect_topology_option_modifier_string)) { - if (sscanf + if (SSCANF (connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1) { diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c index ad39f7d62..c90f48d9b 100644 --- a/src/testing/test_testing_topology_blacklist.c +++ b/src/testing/test_testing_topology_blacklist.c @@ -440,7 +440,7 @@ run (void *cls, char *const *args, const char *cfgfile, "connect_topology_option_modifier", &connect_topology_option_modifier_string)) { - if (sscanf + if (SSCANF (connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1) { diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index feb372c40..e8db98a91 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -1357,7 +1357,7 @@ update_config (void *cls, const char *section, const char *option, GNUNET_asprintf (&single_variable, "single_%s_per_host", section); GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section); - if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival))) + if ((0 == strcmp (option, "PORT")) && (1 == SSCANF (value, "%u", &ival))) { if ((ival != 0) && (GNUNET_YES != @@ -1904,7 +1904,7 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", &p_string)) { - if (sscanf (p_string, "%lf", &logNModifier) != 1) + if (SSCANF (p_string, "%lf", &logNModifier) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -1916,7 +1916,7 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", &p_string)) { - if (sscanf (p_string, "%lf", &probability) != 1) + if (SSCANF (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2017,7 +2017,7 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", &p_string)) { - if (sscanf (p_string, "%lf", &nat_percentage) != 1) + if (SSCANF (p_string, "%lf", &nat_percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2076,7 +2076,7 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", &p_string)) { - if (sscanf (p_string, "%lf", &nat_percentage) != 1) + if (SSCANF (p_string, "%lf", &nat_percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2165,7 +2165,7 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", &p_string)) { - if (sscanf (p_string, "%lf", &percentage) != 1) + if (SSCANF (p_string, "%lf", &percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2185,7 +2185,7 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", &p_string)) { - if (sscanf (p_string, "%lf", &probability) != 1) + if (SSCANF (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2322,7 +2322,7 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", &p_string)) { - if (sscanf (p_string, "%lf", &probability) != 1) + if (SSCANF (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -7031,7 +7031,7 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg) data[count] = '\0'; temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); ret = - sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", + SSCANF (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", &temphost->username, &temphost->hostname, &temphost->port); if (3 == ret) { diff --git a/src/testing/testing_peergroup.c b/src/testing/testing_peergroup.c index 0119d6670..50f53dd1b 100644 --- a/src/testing/testing_peergroup.c +++ b/src/testing/testing_peergroup.c @@ -932,7 +932,7 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, "connect_topology_option_modifier", &temp_str)) { - if (sscanf + if (SSCANF (temp_str, "%lf", &pg_start_ctx->connect_topology_option_modifier) != 1) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, diff --git a/src/transport/gnunet-transport-wlan-sender.c b/src/transport/gnunet-transport-wlan-sender.c index 9f06b63b4..651b4d413 100644 --- a/src/transport/gnunet-transport-wlan-sender.c +++ b/src/transport/gnunet-transport-wlan-sender.c @@ -136,7 +136,7 @@ main (int argc, char *argv[]) return 1; } if (6 != - sscanf (argv[3], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2], + SSCANF (argv[3], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2], &temp[3], &temp[4], &temp[5])) { fprintf (stderr, @@ -145,7 +145,7 @@ main (int argc, char *argv[]) return 1; } if (6 != - sscanf (argv[2], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2], + SSCANF (argv[2], "%x-%x-%x-%x-%x-%x", &temp[0], &temp[1], &temp[2], &temp[3], &temp[4], &temp[5])) { fprintf (stderr, diff --git a/src/util/configuration.c b/src/util/configuration.c index 6ec9a7183..d006ed3ef 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -197,19 +197,19 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, for (i = strlen (line) - 1; (i >= 0) && (isspace ((unsigned char) line[i])); i--) line[i] = '\0'; - if (1 == sscanf (line, "@INLINE@ %191[^\n]", value)) + if (1 == SSCANF (line, "@INLINE@ %191[^\n]", value)) { /* @INLINE@ value */ if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, value)) ret = GNUNET_SYSERR; /* failed to parse included config */ } - else if (1 == sscanf (line, "[%99[^]]]", value)) + else if (1 == SSCANF (line, "[%99[^]]]", value)) { /* [value] */ GNUNET_free (section); section = GNUNET_strdup (value); } - else if (2 == sscanf (line, " %63[^= ] = %191[^\n]", tag, value)) + else if (2 == SSCANF (line, " %63[^= ] = %191[^\n]", tag, value)) { /* tag = value */ /* Strip LF */ @@ -233,7 +233,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, } GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, &value[i]); } - else if (1 == sscanf (line, " %63[^= ] =[^\n]", tag)) + else if (1 == SSCANF (line, " %63[^= ] =[^\n]", tag)) { /* tag = */ GNUNET_CONFIGURATION_set_value_string (cfg, section, tag, ""); diff --git a/src/util/os_installation.c b/src/util/os_installation.c index b82813d74..e790ce10e 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -62,7 +62,7 @@ get_path_from_proc_maps () while (NULL != fgets (line, sizeof (line), f)) { if ((1 == - sscanf (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir)) && + SSCANF (line, "%*x-%*x %*c%*c%*c%*c %*x %*2u:%*2u %*u%*[ ]%s", dir)) && (NULL != (lgu = strstr (dir, "libgnunetutil")))) { lgu[0] = '\0'; diff --git a/src/util/pseudonym.c b/src/util/pseudonym.c index dd8ad08b3..2d0bf3fad 100644 --- a/src/util/pseudonym.c +++ b/src/util/pseudonym.c @@ -461,7 +461,7 @@ GNUNET_PSEUDONYM_name_to_id (const struct GNUNET_CONFIGURATION_Handle *cfg, idx = -1; slen = strlen (ns_uname); - while ((slen > 0) && (1 != sscanf (&ns_uname[slen - 1], "-%u", &idx))) + while ((slen > 0) && (1 != SSCANF (&ns_uname[slen - 1], "-%u", &idx))) slen--; if (slen == 0) return GNUNET_SYSERR; diff --git a/src/util/service.c b/src/util/service.c index 243e7daa9..7583dccb6 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -106,7 +106,7 @@ parse_ipv4_specification (const char *routeList) while (i < count) { cnt = - sscanf (&routeList[pos], "%u.%u.%u.%u/%u.%u.%u.%u;", &temps[0], + SSCANF (&routeList[pos], "%u.%u.%u.%u/%u.%u.%u.%u;", &temps[0], &temps[1], &temps[2], &temps[3], &temps[4], &temps[5], &temps[6], &temps[7]); if (cnt == 8) @@ -133,7 +133,7 @@ parse_ipv4_specification (const char *routeList) } /* try second notation */ cnt = - sscanf (&routeList[pos], "%u.%u.%u.%u/%u;", &temps[0], &temps[1], + SSCANF (&routeList[pos], "%u.%u.%u.%u/%u;", &temps[0], &temps[1], &temps[2], &temps[3], &slash); if (cnt == 5) { @@ -176,7 +176,7 @@ parse_ipv4_specification (const char *routeList) /* try third notation */ slash = 32; cnt = - sscanf (&routeList[pos], "%u.%u.%u.%u;", &temps[0], &temps[1], + SSCANF (&routeList[pos], "%u.%u.%u.%u;", &temps[0], &temps[1], &temps[2], &temps[3]); if (cnt == 4) { @@ -1268,9 +1268,9 @@ setup_service (struct GNUNET_SERVICE_Context *sctx) #ifndef MINGW errno = 0; if ((NULL != (lpid = getenv ("LISTEN_PID"))) && - (1 == sscanf (lpid, "%u", &pid)) && (getpid () == (pid_t) pid) && + (1 == SSCANF (lpid, "%u", &pid)) && (getpid () == (pid_t) pid) && (NULL != (nfds = getenv ("LISTEN_FDS"))) && - (1 == sscanf (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && + (1 == SSCANF (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) && (cnt + 4 < FD_SETSIZE)) { sctx->lsocks = diff --git a/src/util/strings.c b/src/util/strings.c index a6a5c7542..0d58ec567 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -235,7 +235,7 @@ GNUNET_STRINGS_fancy_size_to_bytes (const char *fancy_size, { ret += last; last = 0; - if (1 != sscanf (tok, "%llu", &last)) + if (1 != SSCANF (tok, "%llu", &last)) { GNUNET_free (in); return GNUNET_SYSERR; /* expected number */ @@ -314,7 +314,7 @@ GNUNET_STRINGS_fancy_time_to_relative (const char *fancy_size, { ret += last; last = 0; - if (1 != sscanf (tok, "%llu", &last)) + if (1 != SSCANF (tok, "%llu", &last)) { GNUNET_free (in); return GNUNET_SYSERR; /* expected number */ @@ -978,7 +978,7 @@ GNUNET_STRINGS_to_address_ipv6 (char *zt_addr, uint16_t addrlen, port_colon = strrchr (zt_addr, ':'); if (port_colon == NULL) return GNUNET_SYSERR; - ret = sscanf (port_colon, ":%u", &port); + ret = SSCANF (port_colon, ":%u", &port); if (ret != 1 || port > 65535) return GNUNET_SYSERR; port_colon[0] = '\0'; @@ -1012,7 +1012,7 @@ GNUNET_STRINGS_to_address_ipv4 (char *zt_addr, uint16_t addrlen, if (addrlen < 9) return GNUNET_SYSERR; - cnt = sscanf (zt_addr, "%u.%u.%u.%u:%u", &temps[0], &temps[1], &temps[2], &temps[3], &port); + cnt = SSCANF (zt_addr, "%u.%u.%u.%u:%u", &temps[0], &temps[1], &temps[2], &temps[3], &port); if (cnt != 5) return GNUNET_SYSERR;