aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-28 16:45:16 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-28 16:45:16 +0000
commitd77a90df90775e88dd10c8e4963132d33cd4f3ef (patch)
tree8993d58e2322a2a9d2422be8d077a27b668312f9
parent677ef8f7fad539bf9ba744a32716ebdfc51a5a42 (diff)
downloadgnunet-d77a90df90775e88dd10c8e4963132d33cd4f3ef.tar.gz
gnunet-d77a90df90775e88dd10c8e4963132d33cd4f3ef.zip
-fixing use of uninitialized variable, some code cleanup, fixing memory leak on error path
-rw-r--r--contrib/gnunet.doxy4
-rw-r--r--src/fs/gnunet-service-fs_lc.c2
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c5
-rw-r--r--src/transport/transport-testing.c51
4 files changed, 30 insertions, 32 deletions
diff --git a/contrib/gnunet.doxy b/contrib/gnunet.doxy
index 2477dcef2..ababbb379 100644
--- a/contrib/gnunet.doxy
+++ b/contrib/gnunet.doxy
@@ -253,12 +253,12 @@ PERLMOD_MAKEVAR_PREFIX =
253# Configuration options related to the preprocessor 253# Configuration options related to the preprocessor
254#--------------------------------------------------------------------------- 254#---------------------------------------------------------------------------
255ENABLE_PREPROCESSING = YES 255ENABLE_PREPROCESSING = YES
256MACRO_EXPANSION = NO 256MACRO_EXPANSION = YES
257EXPAND_ONLY_PREDEF = NO 257EXPAND_ONLY_PREDEF = NO
258SEARCH_INCLUDES = YES 258SEARCH_INCLUDES = YES
259INCLUDE_PATH = 259INCLUDE_PATH =
260INCLUDE_FILE_PATTERNS = 260INCLUDE_FILE_PATTERNS =
261PREDEFINED = 261PREDEFINED = GNUNET_UNUSED="" GNUNET_PACKED=""
262EXPAND_AS_DEFINED = 262EXPAND_AS_DEFINED =
263SKIP_FUNCTION_MACROS = YES 263SKIP_FUNCTION_MACROS = YES
264#--------------------------------------------------------------------------- 264#---------------------------------------------------------------------------
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c
index c6ba4617e..65dece707 100644
--- a/src/fs/gnunet-service-fs_lc.c
+++ b/src/fs/gnunet-service-fs_lc.c
@@ -286,7 +286,7 @@ client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
286 * 286 *
287 * @param client identification of the client 287 * @param client identification of the client
288 * @param message the actual message 288 * @param message the actual message
289 * @param ptptr where to store the pending request handle for the request 289 * @param prptr where to store the pending request handle for the request
290 * @return GNUNET_YES to start local processing, 290 * @return GNUNET_YES to start local processing,
291 * GNUNET_NO to not (yet) start local processing, 291 * GNUNET_NO to not (yet) start local processing,
292 * GNUNET_SYSERR on error 292 * GNUNET_SYSERR on error
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index b0fb03e29..b10f124d4 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -137,7 +137,12 @@ core_init (void *cls, struct GNUNET_CORE_Handle *server,
137/** 137/**
138 * Core handler for p2p hostlist advertisements 138 * Core handler for p2p hostlist advertisements
139 * 139 *
140 * @param cls closure
141 * @param peer identity of the sender
142 * @param message advertisement message we got
143 * @param atsi performance information
140 * @param atsi_count number of records in 'atsi' 144 * @param atsi_count number of records in 'atsi'
145 * @return GNUNET_OK on success
141 */ 146 */
142static int 147static int
143advertisement_handler (void *cls, const struct GNUNET_PeerIdentity *peer, 148advertisement_handler (void *cls, const struct GNUNET_PeerIdentity *peer,
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index a8f034c9c..e45953239 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -362,7 +362,6 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
362 void *cb_cls) 362 void *cb_cls)
363{ 363{
364 struct GNUNET_DISK_FileHandle *fn; 364 struct GNUNET_DISK_FileHandle *fn;
365 int success = GNUNET_OK;
366 365
367 GNUNET_assert (tth != NULL); 366 GNUNET_assert (tth != NULL);
368 GNUNET_assert (p != NULL); 367 GNUNET_assert (p != NULL);
@@ -406,35 +405,30 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
406 GNUNET_i2s (&p->id)); 405 GNUNET_i2s (&p->id));
407#endif 406#endif
408 407
409 sleep (5); 408 sleep (5); // YUCK!
410 409
411 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) 410 if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO)
412 { 411 {
413 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", 412 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing",
414 "File not found: `%s' \n", cfgname); 413 "File not found: `%s' \n", cfgname);
415 success = GNUNET_SYSERR; 414 goto fail;
416 goto fail;
417 } 415 }
418 416
419 p->cfg = GNUNET_CONFIGURATION_create (); 417 p->cfg = GNUNET_CONFIGURATION_create ();
420 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 418 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
421 if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) 419
420 if (! GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME"))
421 goto fail;
422 422
423 fn = GNUNET_DISK_file_open (p->hostkeyfile, 423 fn = GNUNET_DISK_file_open (p->hostkeyfile,
424 GNUNET_DISK_OPEN_READWRITE | 424 GNUNET_DISK_OPEN_READWRITE |
425 GNUNET_DISK_OPEN_CREATE, 425 GNUNET_DISK_OPEN_CREATE,
426 GNUNET_DISK_PERM_USER_READ | 426 GNUNET_DISK_PERM_USER_READ |
427 GNUNET_DISK_PERM_USER_WRITE); 427 GNUNET_DISK_PERM_USER_WRITE);
428 if (fn == NULL) 428 if (fn == NULL)
429 {
430 success = GNUNET_SYSERR;
431 goto fail; 429 goto fail;
432 }
433 if (GNUNET_OK != GNUNET_DISK_file_close (fn)) 430 if (GNUNET_OK != GNUNET_DISK_file_close (fn))
434 {
435 success = GNUNET_SYSERR;
436 goto fail; 431 goto fail;
437 }
438 432
439 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 433 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
440 "gnunet-service-arm", "-c", cfgname, 434 "gnunet-service-arm", "-c", cfgname,
@@ -455,16 +449,14 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t
455 449
456 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); 450 p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p);
457 GNUNET_assert (p->ghh != NULL); 451 GNUNET_assert (p->ghh != NULL);
452 return GNUNET_OK;
458 453
459 fail: 454 fail:
460 if (success == GNUNET_SYSERR) 455 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing",
461 { 456 "Restarting peer %u (`%s') failed, removing peer\n", p->no,
462 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", 457 GNUNET_i2s (&p->id));
463 "Restarting peer %u (`%s') failed, removing peer\n", p->no, 458 GNUNET_TRANSPORT_TESTING_stop_peer (tth,p);
464 GNUNET_i2s (&p->id)); 459 return GNUNET_SYSERR;
465 GNUNET_TRANSPORT_TESTING_stop_peer (tth,p);
466 }
467 return success;
468} 460}
469 461
470/** 462/**
@@ -642,16 +634,16 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth)
642struct GNUNET_TRANSPORT_TESTING_handle * 634struct GNUNET_TRANSPORT_TESTING_handle *
643GNUNET_TRANSPORT_TESTING_init () 635GNUNET_TRANSPORT_TESTING_init ()
644{ 636{
645 struct GNUNET_TRANSPORT_TESTING_handle *tth = 637 struct GNUNET_TRANSPORT_TESTING_handle *tth;
646 GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
647 struct GNUNET_DISK_FileHandle *fd; 638 struct GNUNET_DISK_FileHandle *fd;
648 uint64_t fs; 639 uint64_t fs;
649 uint64_t total_hostkeys; 640 uint64_t total_hostkeys;
650 641
651 642
652 /* prepare hostkeys */ 643 /* prepare hostkeys */
644 tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle));
653 tth->hostkey_data = NULL; 645 tth->hostkey_data = NULL;
654 char * hostkeys_file = "../../contrib/testing_hostkeys.dat"; 646 const char * hostkeys_file = "../../contrib/testing_hostkeys.dat";
655 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) 647 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
656 { 648 {
657 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 649 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -666,6 +658,7 @@ GNUNET_TRANSPORT_TESTING_init ()
666 { 658 {
667 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", 659 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
668 hostkeys_file); 660 hostkeys_file);
661 GNUNET_free (tth);
669 return NULL; 662 return NULL;
670 } 663 }
671 664