summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-10-10 09:13:03 +0200
committerChristian Grothoff <christian@grothoff.org>2018-10-10 09:13:03 +0200
commit79984bff9bbec195e0fc7af04648cdd31024a18e (patch)
tree3f82e3af4fd9909661056c32ae5860a9ba07cc3b /src
parente0f72735afe8340b12d4b83d05281062ee141cdc (diff)
code cleanup, remove/simplify bogus check
Diffstat (limited to 'src')
-rw-r--r--src/namestore/gnunet-service-namestore.c20
-rw-r--r--src/namestore/test_namestore_api_monitoring_existing.c104
2 files changed, 56 insertions, 68 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index 101f2bd45..2286abecc 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -922,7 +922,7 @@ continue_store_activity (struct StoreActivity *sa)
sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) )
{
sa->zm_pos = zm->next; /* not interesting to this monitor */
- // continue; -- fails tests, but why not here?
+ continue; // -- fails tests, but why not here?
}
if (zm->limit == zm->iteration_cnt)
{
@@ -1980,23 +1980,9 @@ monitor_iterate_cb (void *cls,
{
struct ZoneMonitor *zm = cls;
- if ( (0 != memcmp (&zone_key,
- &zm->zone,
- sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) &&
- (0 != memcmp (&zm->zone,
- &zero,
- sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) )
- {
- GNUNET_break (0);
- return;
- }
zm->seq = seq;
- if (NULL == name)
- {
- /* finished with iteration */
- monitor_sync (zm);
- return;
- }
+ GNUNET_assert (NULL != name);
+ GNUNET_assert (zone_key == &zm->zone);
GNUNET_STATISTICS_update (statistics,
"Monitor notifications sent",
1,
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c
index 9c8ddf7ad..867f18b27 100644
--- a/src/namestore/test_namestore_api_monitoring_existing.c
+++ b/src/namestore/test_namestore_api_monitoring_existing.c
@@ -44,15 +44,15 @@ static struct GNUNET_NAMESTORE_ZoneMonitor *zm;
static int res;
-static char * s_name_1;
+static const char * s_name_1;
static struct GNUNET_GNSRECORD_Data *s_rd_1;
-static char * s_name_2;
+static const char * s_name_2;
static struct GNUNET_GNSRECORD_Data *s_rd_2;
-static char * s_name_3;
+static const char * s_name_3;
static struct GNUNET_GNSRECORD_Data *s_rd_3;
@@ -107,27 +107,21 @@ end (void *cls)
GNUNET_NAMESTORE_disconnect (nsh);
nsh = NULL;
}
-
- GNUNET_free_non_null(s_name_1);
- GNUNET_free_non_null(s_name_2);
- GNUNET_free_non_null(s_name_3);
-
- if (s_rd_1 != NULL)
+ if (NULL != s_rd_1)
{
GNUNET_free ((void *)s_rd_1->data);
GNUNET_free (s_rd_1);
}
- if (s_rd_2 != NULL)
+ if (NULL != s_rd_2)
{
GNUNET_free ((void *)s_rd_2->data);
GNUNET_free (s_rd_2);
}
- if (s_rd_3 != NULL)
+ if (NULL != s_rd_3)
{
GNUNET_free ((void *)s_rd_3->data);
GNUNET_free (s_rd_3);
}
-
if (NULL != privkey)
{
GNUNET_free (privkey);
@@ -154,43 +148,45 @@ zone_proc (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Comparing results name %s\n",
name);
-
if (0 != memcmp (zone_key,
privkey,
sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Monitoring returned wrong zone key\n");
+ "Monitoring returned wrong zone key\n");
GNUNET_break (0);
GNUNET_SCHEDULER_shutdown ();
return;
}
- if (0 == strcmp (name, s_name_1))
+ if (0 == strcmp (name,
+ s_name_1))
{
if (GNUNET_YES !=
GNUNET_GNSRECORD_records_cmp (rd,
s_rd_1))
{
GNUNET_break (0);
- fail = GNUNET_YES;
+ fail = GNUNET_YES;
}
}
- else if (0 == strcmp (name, s_name_2))
+ else if (0 == strcmp (name,
+ s_name_2))
{
if (GNUNET_YES !=
GNUNET_GNSRECORD_records_cmp (rd,
s_rd_2))
{
GNUNET_break (0);
- fail = GNUNET_YES;
+ fail = GNUNET_YES;
}
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Invalid name %s\n", name);
- GNUNET_break (0);
+ "Invalid name %s\n",
+ name);
+ GNUNET_break (0);
fail = GNUNET_YES;
}
GNUNET_NAMESTORE_zone_monitor_next (zm,
@@ -231,14 +227,17 @@ put_cont (void *cls,
const char *emsg)
{
static int c = 0;
- char *label = cls;
+ const char *label = cls;
- if (0 == strcmp (label, s_name_1))
- ns_ops[0] = NULL;
- else if (0 == strcmp (label, s_name_2))
- ns_ops[1] = NULL;
- else if (0 == strcmp (label, s_name_3))
- ns_ops[2] = NULL;
+ if (0 == strcmp (label,
+ s_name_1))
+ ns_ops[0] = NULL;
+ else if (0 == strcmp (label,
+ s_name_2))
+ ns_ops[1] = NULL;
+ else if (0 == strcmp (label,
+ s_name_3))
+ ns_ops[2] = NULL;
if (success == GNUNET_OK)
{
@@ -286,7 +285,7 @@ put_cont (void *cls,
static struct GNUNET_GNSRECORD_Data *
create_record (unsigned int count)
{
- struct GNUNET_GNSRECORD_Data * rd;
+ struct GNUNET_GNSRECORD_Data *rd;
rd = GNUNET_new_array (count,
struct GNUNET_GNSRECORD_Data);
@@ -312,7 +311,9 @@ run (void *cls,
{
res = 1;
privkey = GNUNET_CRYPTO_ecdsa_key_create ();
- GNUNET_assert (privkey != NULL);
+ GNUNET_assert (NULL != privkey);
+ privkey2 = GNUNET_CRYPTO_ecdsa_key_create ();
+ GNUNET_assert (NULL != privkey2);
cfg = mycfg;
GNUNET_SCHEDULER_add_shutdown (&end,
@@ -324,19 +325,18 @@ run (void *cls,
nsh = GNUNET_NAMESTORE_connect (cfg);
if (NULL == nsh)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Connect to namestore\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Connect to namestore failed\n");
GNUNET_break (0);
- endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
+ endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly,
+ NULL);
return;
}
- privkey2 = GNUNET_CRYPTO_ecdsa_key_create ();
- GNUNET_assert (privkey2 != NULL);
-
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Created record 3\n");
/* name in different zone */
- GNUNET_asprintf(&s_name_3, "dummy3");
+ s_name_3 = "dummy3";
s_rd_3 = create_record(1);
GNUNET_assert (NULL != (ns_ops[2] =
GNUNET_NAMESTORE_records_store (nsh,
@@ -345,24 +345,24 @@ run (void *cls,
1,
s_rd_3,
&put_cont,
- s_name_3)));
+ (void *) s_name_3)));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Created record 1\n");
- GNUNET_asprintf(&s_name_1, "dummy1");
- s_rd_1 = create_record(1);
+ s_name_1 = "dummy1";
+ s_rd_1 = create_record (1);
GNUNET_assert (NULL != (ns_ops[0] =
- GNUNET_NAMESTORE_records_store(nsh,
- privkey,
- s_name_1,
- 1,
- s_rd_1,
- &put_cont,
- s_name_1)));
+ GNUNET_NAMESTORE_records_store (nsh,
+ privkey,
+ s_name_1,
+ 1,
+ s_rd_1,
+ &put_cont,
+ (void *) s_name_1)));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Created record 2 \n");
- GNUNET_asprintf(&s_name_2, "dummy2");
- s_rd_2 = create_record(1);
+ s_name_2 = "dummy2";
+ s_rd_2 = create_record (1);
GNUNET_assert (NULL != (ns_ops[1] =
GNUNET_NAMESTORE_records_store (nsh,
privkey,
@@ -370,12 +370,13 @@ run (void *cls,
1,
s_rd_2,
&put_cont,
- s_name_2)));
+ (void *) s_name_2)));
}
int
-main (int argc, char *argv[])
+main (int argc,
+ char *argv[])
{
const char *plugin_name;
char *cfg_name;
@@ -393,6 +394,7 @@ main (int argc, char *argv[])
&run,
NULL))
{
+ GNUNET_break (0);
res = 1;
}
GNUNET_DISK_purge_cfg_dir (cfg_name,