aboutsummaryrefslogtreecommitdiff
path: root/src/util/configuration.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-01-04 16:46:18 +0100
committerChristian Grothoff <christian@grothoff.org>2018-01-04 16:46:18 +0100
commite20eca334a33b8340524a8fa6ad1d6b606e1dd0c (patch)
treee79ce20f787cae4aea7403d2e9c9b8fb2546ad1f /src/util/configuration.c
parent056ca89d207cd1865a90fe3fcd430a4381097da5 (diff)
downloadgnunet-e20eca334a33b8340524a8fa6ad1d6b606e1dd0c.tar.gz
gnunet-e20eca334a33b8340524a8fa6ad1d6b606e1dd0c.zip
fix timeout of test_service, misc signed/unsigned and unused argument issues
Diffstat (limited to 'src/util/configuration.c')
-rw-r--r--src/util/configuration.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c
index f63903b4e..7f1d98902 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -324,6 +324,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
324 char *endsep; 324 char *endsep;
325 int dirty; 325 int dirty;
326 int ret; 326 int ret;
327 ssize_t sret;
327 328
328 fn = GNUNET_STRINGS_filename_expand (filename); 329 fn = GNUNET_STRINGS_filename_expand (filename);
329 LOG (GNUNET_ERROR_TYPE_DEBUG, 330 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -333,7 +334,10 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
333 return GNUNET_SYSERR; 334 return GNUNET_SYSERR;
334 dirty = cfg->dirty; /* back up value! */ 335 dirty = cfg->dirty; /* back up value! */
335 if (GNUNET_SYSERR == 336 if (GNUNET_SYSERR ==
336 GNUNET_DISK_file_size (fn, &fs64, GNUNET_YES, GNUNET_YES)) 337 GNUNET_DISK_file_size (fn,
338 &fs64,
339 GNUNET_YES,
340 GNUNET_YES))
337 { 341 {
338 LOG (GNUNET_ERROR_TYPE_WARNING, 342 LOG (GNUNET_ERROR_TYPE_WARNING,
339 "Error while determining the file size of `%s'\n", 343 "Error while determining the file size of `%s'\n",
@@ -349,7 +353,11 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg,
349 } 353 }
350 fs = fs64; 354 fs = fs64;
351 mem = GNUNET_malloc (fs); 355 mem = GNUNET_malloc (fs);
352 if (fs != GNUNET_DISK_fn_read (fn, mem, fs)) 356 sret = GNUNET_DISK_fn_read (fn,
357 mem,
358 fs);
359 if ( (sret < 0) ||
360 (fs != (size_t) sret) )
353 { 361 {
354 LOG (GNUNET_ERROR_TYPE_WARNING, 362 LOG (GNUNET_ERROR_TYPE_WARNING,
355 _("Error while reading file `%s'\n"), 363 _("Error while reading file `%s'\n"),
@@ -495,6 +503,7 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
495 char *fn; 503 char *fn;
496 char *cfg_buf; 504 char *cfg_buf;
497 size_t size; 505 size_t size;
506 ssize_t sret;
498 507
499 fn = GNUNET_STRINGS_filename_expand (filename); 508 fn = GNUNET_STRINGS_filename_expand (filename);
500 if (fn == NULL) 509 if (fn == NULL)
@@ -505,11 +514,13 @@ GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
505 return GNUNET_SYSERR; 514 return GNUNET_SYSERR;
506 } 515 }
507 cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, &size); 516 cfg_buf = GNUNET_CONFIGURATION_serialize (cfg, &size);
508 if (size != GNUNET_DISK_fn_write (fn, cfg_buf, size, 517 sret = GNUNET_DISK_fn_write (fn, cfg_buf, size,
509 GNUNET_DISK_PERM_USER_READ 518 GNUNET_DISK_PERM_USER_READ
510 | GNUNET_DISK_PERM_USER_WRITE 519 | GNUNET_DISK_PERM_USER_WRITE
511 | GNUNET_DISK_PERM_GROUP_READ 520 | GNUNET_DISK_PERM_GROUP_READ
512 | GNUNET_DISK_PERM_GROUP_WRITE)) 521 | GNUNET_DISK_PERM_GROUP_WRITE);
522 if ( (sret < 0) ||
523 (size != (size_t) sret) )
513 { 524 {
514 GNUNET_free (fn); 525 GNUNET_free (fn);
515 GNUNET_free (cfg_buf); 526 GNUNET_free (cfg_buf);
@@ -858,13 +869,20 @@ GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg,
858 */ 869 */
859void 870void
860GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, 871GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg,
861 const char *section, const char *option, 872 const char *section,
873 const char *option,
862 unsigned long long number) 874 unsigned long long number)
863{ 875{
864 char s[64]; 876 char s[64];
865 877
866 GNUNET_snprintf (s, 64, "%llu", number); 878 GNUNET_snprintf (s,
867 GNUNET_CONFIGURATION_set_value_string (cfg, section, option, s); 879 64,
880 "%llu",
881 number);
882 GNUNET_CONFIGURATION_set_value_string (cfg,
883 section,
884 option,
885 s);
868} 886}
869 887
870 888