From d77a90df90775e88dd10c8e4963132d33cd4f3ef Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 28 Nov 2011 16:45:16 +0000 Subject: [PATCH] -fixing use of uninitialized variable, some code cleanup, fixing memory leak on error path --- contrib/gnunet.doxy | 4 +-- src/fs/gnunet-service-fs_lc.c | 2 +- src/hostlist/gnunet-daemon-hostlist.c | 5 +++ src/transport/transport-testing.c | 51 ++++++++++++--------------- 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 = # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO +MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = -PREDEFINED = +PREDEFINED = GNUNET_UNUSED="" GNUNET_PACKED="" EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- 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, * * @param client identification of the client * @param message the actual message - * @param ptptr where to store the pending request handle for the request + * @param prptr where to store the pending request handle for the request * @return GNUNET_YES to start local processing, * GNUNET_NO to not (yet) start local processing, * 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, /** * Core handler for p2p hostlist advertisements * + * @param cls closure + * @param peer identity of the sender + * @param message advertisement message we got + * @param atsi performance information * @param atsi_count number of records in 'atsi' + * @return GNUNET_OK on success */ static int advertisement_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 void *cb_cls) { struct GNUNET_DISK_FileHandle *fn; - int success = GNUNET_OK; GNUNET_assert (tth != NULL); GNUNET_assert (p != NULL); @@ -406,35 +405,30 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t GNUNET_i2s (&p->id)); #endif - sleep (5); + sleep (5); // YUCK! if (GNUNET_DISK_file_test (cfgname) == GNUNET_NO) { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", - "File not found: `%s' \n", cfgname); - success = GNUNET_SYSERR; - goto fail; + GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "transport-testing", + "File not found: `%s' \n", cfgname); + goto fail; } p->cfg = GNUNET_CONFIGURATION_create (); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); - if (GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) + + if (! GNUNET_CONFIGURATION_have_value (p->cfg, "PATHS", "SERVICEHOME")) + goto fail; fn = GNUNET_DISK_file_open (p->hostkeyfile, - GNUNET_DISK_OPEN_READWRITE | - GNUNET_DISK_OPEN_CREATE, - GNUNET_DISK_PERM_USER_READ | - GNUNET_DISK_PERM_USER_WRITE); + GNUNET_DISK_OPEN_READWRITE | + GNUNET_DISK_OPEN_CREATE, + GNUNET_DISK_PERM_USER_READ | + GNUNET_DISK_PERM_USER_WRITE); if (fn == NULL) - { - success = GNUNET_SYSERR; goto fail; - } if (GNUNET_OK != GNUNET_DISK_file_close (fn)) - { - success = GNUNET_SYSERR; goto fail; - } p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", "gnunet-service-arm", "-c", cfgname, @@ -455,16 +449,14 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle *t p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &get_hello, p); GNUNET_assert (p->ghh != NULL); + return GNUNET_OK; - fail: - if (success == GNUNET_SYSERR) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", - "Restarting peer %u (`%s') failed, removing peer\n", p->no, - GNUNET_i2s (&p->id)); - GNUNET_TRANSPORT_TESTING_stop_peer (tth,p); - } - return success; + fail: + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "transport-testing", + "Restarting peer %u (`%s') failed, removing peer\n", p->no, + GNUNET_i2s (&p->id)); + GNUNET_TRANSPORT_TESTING_stop_peer (tth,p); + return GNUNET_SYSERR; } /** @@ -642,16 +634,16 @@ GNUNET_TRANSPORT_TESTING_done (struct GNUNET_TRANSPORT_TESTING_handle *tth) struct GNUNET_TRANSPORT_TESTING_handle * GNUNET_TRANSPORT_TESTING_init () { - struct GNUNET_TRANSPORT_TESTING_handle *tth = - GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); + struct GNUNET_TRANSPORT_TESTING_handle *tth; struct GNUNET_DISK_FileHandle *fd; uint64_t fs; uint64_t total_hostkeys; /* prepare hostkeys */ + tth = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_TESTING_handle)); tth->hostkey_data = NULL; - char * hostkeys_file = "../../contrib/testing_hostkeys.dat"; + const char * hostkeys_file = "../../contrib/testing_hostkeys.dat"; if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -666,6 +658,7 @@ GNUNET_TRANSPORT_TESTING_init () { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", hostkeys_file); + GNUNET_free (tth); return NULL; } -- 2.25.1