gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: help fixing #7105


From: gnunet
Subject: [gnunet] branch master updated: help fixing #7105
Date: Thu, 25 Nov 2021 23:39:06 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 2a52d39a2 help fixing #7105
2a52d39a2 is described below

commit 2a52d39a20ecc7537a8b890ed611f16dbc7dd8eb
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Nov 25 23:38:58 2021 +0100

    help fixing #7105
---
 src/util/program.c   | 52 +++++++++++++++++++++++++++++++++++++++++-----------
 src/util/scheduler.c |  3 ++-
 2 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/src/util/program.c b/src/util/program.c
index 08effa19b..fb7929b98 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -153,13 +153,14 @@ GNUNET_PROGRAM_run2 (int argc,
   long long clock_offset;
   struct GNUNET_CONFIGURATION_Handle *cfg;
   const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
-  struct GNUNET_GETOPT_CommandLineOption defoptions[] = {
+  const struct GNUNET_GETOPT_CommandLineOption defoptions[] = {
     GNUNET_GETOPT_option_cfgfile (&cc.cfgfile),
     GNUNET_GETOPT_option_help (binaryHelp),
     GNUNET_GETOPT_option_loglevel (&loglev),
     GNUNET_GETOPT_option_logfile (&logfile),
     GNUNET_GETOPT_option_version (pd->version)
   };
+  unsigned int deflen = sizeof(defoptions) / sizeof(defoptions[0]);
   struct GNUNET_GETOPT_CommandLineOption *allopts;
   const char *gargs;
   char *lpfx;
@@ -176,9 +177,13 @@ GNUNET_PROGRAM_run2 (int argc,
     gargv = NULL;
     gargc = 0;
     for (int i = 0; i < argc; i++)
-      GNUNET_array_append (gargv, gargc, GNUNET_strdup (argv[i]));
+      GNUNET_array_append (gargv,
+                           gargc,
+                           GNUNET_strdup (argv[i]));
     cargs = GNUNET_strdup (gargs);
-    for (char *tok = strtok (cargs, " "); NULL != tok; tok = strtok (NULL, " 
"))
+    for (char *tok = strtok (cargs, " ");
+         NULL != tok;
+         tok = strtok (NULL, " "))
       GNUNET_array_append (gargv, gargc, GNUNET_strdup (tok));
     GNUNET_free (cargs);
     GNUNET_array_append (gargv, gargc, NULL);
@@ -209,15 +214,40 @@ GNUNET_PROGRAM_run2 (int argc,
   cnt = 0;
   while (NULL != options[cnt].name)
     cnt++;
-  allopts =
-    GNUNET_malloc ((cnt + 1) * sizeof(struct GNUNET_GETOPT_CommandLineOption)
-                   + sizeof(defoptions));
-  GNUNET_memcpy (allopts, defoptions, sizeof(defoptions));
-  GNUNET_memcpy (&allopts[sizeof(defoptions)
-                          / sizeof(struct GNUNET_GETOPT_CommandLineOption)],
+  allopts = GNUNET_new_array (cnt + deflen + 1,
+                              struct GNUNET_GETOPT_CommandLineOption);
+  GNUNET_memcpy (allopts,
                  options,
-                 (cnt + 1) * sizeof(struct GNUNET_GETOPT_CommandLineOption));
-  cnt += sizeof(defoptions) / sizeof(struct GNUNET_GETOPT_CommandLineOption);
+                 cnt * sizeof(struct GNUNET_GETOPT_CommandLineOption));
+  {
+    unsigned int xtra = 0;
+
+    for (unsigned int i = 0;
+         i<sizeof (defoptions) / sizeof(struct 
GNUNET_GETOPT_CommandLineOption);
+         i++)
+    {
+      bool found = false;
+
+      for (unsigned int j = 0; j<cnt; j++)
+      {
+        found |= ( (options[j].shortName == defoptions[i].shortName) &&
+                   (0 != options[j].shortName) );
+        found |= ( (NULL != options[j].name) &&
+                   (NULL != defoptions[i].name) &&
+                   (0 == strcmp (options[j].name,
+                                 defoptions[i].name)) );
+        if (found)
+          break;
+      }
+      if (found)
+        continue;
+      GNUNET_memcpy (&allopts[cnt + xtra],
+                     &defoptions[i],
+                     sizeof (struct GNUNET_GETOPT_CommandLineOption));
+      xtra++;
+    }
+    cnt += xtra;
+  }
   qsort (allopts,
          cnt,
          sizeof(struct GNUNET_GETOPT_CommandLineOption),
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index d5c7b964f..03a7c0dfb 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -2056,7 +2056,8 @@ GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle 
*sh)
        *
        * It might also mean we are busy-waiting because of a programming
        * error in the external event loop.
-       */LOG (GNUNET_ERROR_TYPE_DEBUG,
+       */
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
            "GNUNET_SCHEDULER_do_work did not find any ready "
            "tasks and timeout has not been reached yet.\n");
     }

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]