diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-25 23:38:58 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-25 23:39:03 +0100 |
commit | 2a52d39a20ecc7537a8b890ed611f16dbc7dd8eb (patch) | |
tree | 5117ab69c0409e41e0a578e7c7eece754e612d11 | |
parent | a24bbd5b39c7d26d97af357531ed05579016bd69 (diff) | |
download | gnunet-2a52d39a20ecc7537a8b890ed611f16dbc7dd8eb.tar.gz gnunet-2a52d39a20ecc7537a8b890ed611f16dbc7dd8eb.zip |
help fixing #7105
-rw-r--r-- | src/util/program.c | 52 | ||||
-rw-r--r-- | 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, | |||
153 | long long clock_offset; | 153 | long long clock_offset; |
154 | struct GNUNET_CONFIGURATION_Handle *cfg; | 154 | struct GNUNET_CONFIGURATION_Handle *cfg; |
155 | const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get (); | 155 | const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get (); |
156 | struct GNUNET_GETOPT_CommandLineOption defoptions[] = { | 156 | const struct GNUNET_GETOPT_CommandLineOption defoptions[] = { |
157 | GNUNET_GETOPT_option_cfgfile (&cc.cfgfile), | 157 | GNUNET_GETOPT_option_cfgfile (&cc.cfgfile), |
158 | GNUNET_GETOPT_option_help (binaryHelp), | 158 | GNUNET_GETOPT_option_help (binaryHelp), |
159 | GNUNET_GETOPT_option_loglevel (&loglev), | 159 | GNUNET_GETOPT_option_loglevel (&loglev), |
160 | GNUNET_GETOPT_option_logfile (&logfile), | 160 | GNUNET_GETOPT_option_logfile (&logfile), |
161 | GNUNET_GETOPT_option_version (pd->version) | 161 | GNUNET_GETOPT_option_version (pd->version) |
162 | }; | 162 | }; |
163 | unsigned int deflen = sizeof(defoptions) / sizeof(defoptions[0]); | ||
163 | struct GNUNET_GETOPT_CommandLineOption *allopts; | 164 | struct GNUNET_GETOPT_CommandLineOption *allopts; |
164 | const char *gargs; | 165 | const char *gargs; |
165 | char *lpfx; | 166 | char *lpfx; |
@@ -176,9 +177,13 @@ GNUNET_PROGRAM_run2 (int argc, | |||
176 | gargv = NULL; | 177 | gargv = NULL; |
177 | gargc = 0; | 178 | gargc = 0; |
178 | for (int i = 0; i < argc; i++) | 179 | for (int i = 0; i < argc; i++) |
179 | GNUNET_array_append (gargv, gargc, GNUNET_strdup (argv[i])); | 180 | GNUNET_array_append (gargv, |
181 | gargc, | ||
182 | GNUNET_strdup (argv[i])); | ||
180 | cargs = GNUNET_strdup (gargs); | 183 | cargs = GNUNET_strdup (gargs); |
181 | for (char *tok = strtok (cargs, " "); NULL != tok; tok = strtok (NULL, " ")) | 184 | for (char *tok = strtok (cargs, " "); |
185 | NULL != tok; | ||
186 | tok = strtok (NULL, " ")) | ||
182 | GNUNET_array_append (gargv, gargc, GNUNET_strdup (tok)); | 187 | GNUNET_array_append (gargv, gargc, GNUNET_strdup (tok)); |
183 | GNUNET_free (cargs); | 188 | GNUNET_free (cargs); |
184 | GNUNET_array_append (gargv, gargc, NULL); | 189 | GNUNET_array_append (gargv, gargc, NULL); |
@@ -209,15 +214,40 @@ GNUNET_PROGRAM_run2 (int argc, | |||
209 | cnt = 0; | 214 | cnt = 0; |
210 | while (NULL != options[cnt].name) | 215 | while (NULL != options[cnt].name) |
211 | cnt++; | 216 | cnt++; |
212 | allopts = | 217 | allopts = GNUNET_new_array (cnt + deflen + 1, |
213 | GNUNET_malloc ((cnt + 1) * sizeof(struct GNUNET_GETOPT_CommandLineOption) | 218 | struct GNUNET_GETOPT_CommandLineOption); |
214 | + sizeof(defoptions)); | 219 | GNUNET_memcpy (allopts, |
215 | GNUNET_memcpy (allopts, defoptions, sizeof(defoptions)); | ||
216 | GNUNET_memcpy (&allopts[sizeof(defoptions) | ||
217 | / sizeof(struct GNUNET_GETOPT_CommandLineOption)], | ||
218 | options, | 220 | options, |
219 | (cnt + 1) * sizeof(struct GNUNET_GETOPT_CommandLineOption)); | 221 | cnt * sizeof(struct GNUNET_GETOPT_CommandLineOption)); |
220 | cnt += sizeof(defoptions) / sizeof(struct GNUNET_GETOPT_CommandLineOption); | 222 | { |
223 | unsigned int xtra = 0; | ||
224 | |||
225 | for (unsigned int i = 0; | ||
226 | i<sizeof (defoptions) / sizeof(struct GNUNET_GETOPT_CommandLineOption); | ||
227 | i++) | ||
228 | { | ||
229 | bool found = false; | ||
230 | |||
231 | for (unsigned int j = 0; j<cnt; j++) | ||
232 | { | ||
233 | found |= ( (options[j].shortName == defoptions[i].shortName) && | ||
234 | (0 != options[j].shortName) ); | ||
235 | found |= ( (NULL != options[j].name) && | ||
236 | (NULL != defoptions[i].name) && | ||
237 | (0 == strcmp (options[j].name, | ||
238 | defoptions[i].name)) ); | ||
239 | if (found) | ||
240 | break; | ||
241 | } | ||
242 | if (found) | ||
243 | continue; | ||
244 | GNUNET_memcpy (&allopts[cnt + xtra], | ||
245 | &defoptions[i], | ||
246 | sizeof (struct GNUNET_GETOPT_CommandLineOption)); | ||
247 | xtra++; | ||
248 | } | ||
249 | cnt += xtra; | ||
250 | } | ||
221 | qsort (allopts, | 251 | qsort (allopts, |
222 | cnt, | 252 | cnt, |
223 | sizeof(struct GNUNET_GETOPT_CommandLineOption), | 253 | 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) | |||
2056 | * | 2056 | * |
2057 | * It might also mean we are busy-waiting because of a programming | 2057 | * It might also mean we are busy-waiting because of a programming |
2058 | * error in the external event loop. | 2058 | * error in the external event loop. |
2059 | */LOG (GNUNET_ERROR_TYPE_DEBUG, | 2059 | */ |
2060 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2060 | "GNUNET_SCHEDULER_do_work did not find any ready " | 2061 | "GNUNET_SCHEDULER_do_work did not find any ready " |
2061 | "tasks and timeout has not been reached yet.\n"); | 2062 | "tasks and timeout has not been reached yet.\n"); |
2062 | } | 2063 | } |