-LRN: use plibc SSCANF instead of sscanf
authorChristian Grothoff <christian@grothoff.org>
Sun, 11 Mar 2012 22:48:04 +0000 (22:48 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 11 Mar 2012 22:48:04 +0000 (22:48 +0000)
17 files changed:
src/dv/test_transport_api_dv.c
src/fs/fs_uri.c
src/nat/gnunet-helper-nat-client.c
src/nat/nat.c
src/nat/nat_mini.c
src/testing/test_testing_group_remote.c
src/testing/test_testing_large_topology.c
src/testing/test_testing_topology.c
src/testing/test_testing_topology_blacklist.c
src/testing/testing_group.c
src/testing/testing_peergroup.c
src/transport/gnunet-transport-wlan-sender.c
src/util/configuration.c
src/util/os_installation.c
src/util/pseudonym.c
src/util/service.c
src/util/strings.c

index 386ea5f29c05661206b992e253bec4afded154ec..6165a9db2f9cffa667d297571357c443c33b6f2f 100644 (file)
@@ -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)
     {
index 43cf2c5bddfec1dd07f105574f4f1220fcc59251..db9b7d16699d6c0c0a7e31fa6449b6456002ed7c 100644 (file)
@@ -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"));
index 73504ab1dec311b8b4092881c1935a85e9df91a0..cc51fb575e6e9171dbf1dc0235f43213acc27a52 100644 (file)
@@ -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;
index 725bbe9521801082ea779cb1c7928cca2a8cea67..53301ebb128684e4262b67ff32c885c9e5467679 100644 (file)
@@ -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? */
index 830fdfd5027fe493daa4578fbef2abd74d8ab711..84cc841867bd254781772079e4cad653711fd30b 100644 (file)
@@ -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 */
   }
index e300f95e3588e4b0fdef0709749bd7e5968f3816..b06655ca4ee4a31d9178aae40f758d89800a95f2 100644 (file)
@@ -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)
         {
index 605761105b85459fe35f2d078e4b0d5b400d470e..ad6d973d24ec09465151bdc889b04f7ef077bc14 100644 (file)
@@ -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)
     {
index ba5e23791d26cf9e58fbef720204a55fabe83144..112838f2f8d1e5305fcaded60de71964249544d6 100644 (file)
@@ -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)
     {
index ad39f7d62f0ae421075be095ac5b4b1302d2976c..c90f48d9b4bda61f1a4dafe5ccd5a55c8555ee04 100644 (file)
@@ -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)
     {
index feb372c408e067a6dcba88abcd4428b30552689b..e8db98a91add24e7312017a5ec0dce62c4a3b839 100644 (file)
@@ -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)
         {
index 0119d667046d69c20cf90d0a9d5419537315432b..50f53dd1b701df1bd97d0be05ae9ce2fee98ce67 100644 (file)
@@ -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,
index 9f06b63b46782a3766462caed37a438555be0b4b..651b4d413482ac8f75e3512b4d9c4dd3af7dd3e2 100644 (file)
@@ -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,
index 6ec9a718349316fb51949aad33b35a11fdf92ab1..d006ed3ef3e10ba24968a4c881d754140b11f345 100644 (file)
@@ -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, "");
index b82813d74dccc1efc70bf21551d0e95122fd07c9..e790ce10eec9b46a187431a5d0e1ccab86248ff2 100644 (file)
@@ -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';
index dd8ad08b3b6b3b784bf56a407a1ae6c4bc1c1e70..2d0bf3fadb1259629ab1769d3c029d0882698dea 100644 (file)
@@ -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;
index 243e7daa9572d00e5797dca4c421627983e4b8dd..7583dccb6d78b6cd59d413f13eca09b46d01eb90 100644 (file)
@@ -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 =
index a6a5c7542a45fcca4c7cf279dbbd4a936dd80370..0d58ec567b286546fa4f468a2e75666bde9afbae 100644 (file)
@@ -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;