From 6ffe3aeeacef611c3c34d18fd6b74763ca013b7c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 21 Feb 2017 20:11:20 +0100 Subject: [PATCH] handle errors without crashing --- src/namestore/test_namestore_api_remove.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/namestore/test_namestore_api_remove.c b/src/namestore/test_namestore_api_remove.c index c6c439e86..2d670c1ee 100644 --- a/src/namestore/test_namestore_api_remove.c +++ b/src/namestore/test_namestore_api_remove.c @@ -98,19 +98,22 @@ remove_cont (void *cls, int32_t success, const char *emsg) { + nsqe = NULL; if (GNUNET_YES != success) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Records could not be removed: `%s'\n"), emsg); - if (endbadly_task != NULL) + _("Records could not be removed: `%s'\n"), + emsg); + if (NULL != endbadly_task) GNUNET_SCHEDULER_cancel (endbadly_task); - endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); + endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, + NULL); return; } GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Records were removed, perform lookup\n"); removed = GNUNET_YES; - if (endbadly_task != NULL) + if (NULL != endbadly_task) GNUNET_SCHEDULER_cancel (endbadly_task); GNUNET_SCHEDULER_add_now (&end, NULL); } @@ -139,8 +142,11 @@ put_cont (void *cls, int32_t success, "Name store added record for `%s': %s\n", name, (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); - nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, name, - 0, NULL, &remove_cont, (void *) name); + nsqe = GNUNET_NAMESTORE_records_store (nsh, + privkey, + name, + 0, NULL, + &remove_cont, (void *) name); } -- 2.25.1