summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-12 09:36:33 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-12 09:36:33 +0200
commit99f8204531ebb4d388eec7919afd4b7a3ae0b096 (patch)
tree8c606540b59d1cf0d8ee23114b54112c271af400
parentbe3bbfb4728669698ad7dabb5e0d8648d31a43a8 (diff)
fix: GNUNET_is_zero(ptr) should return enum GNUNET_GenericReturnValue. Fixes #6475.
-rw-r--r--src/ats/ats_api_performance.c2
-rw-r--r--src/ats/gnunet-service-ats_addresses.c2
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c2
-rw-r--r--src/include/gnunet_common.h6
-rw-r--r--src/namestore/gnunet-service-namestore.c4
-rw-r--r--src/namestore/namestore_api_monitor.c2
-rw-r--r--src/transport/gnunet-service-tng.c2
-rw-r--r--src/util/common_allocation.c8
-rw-r--r--src/util/service.c2
-rw-r--r--src/util/test_peer.c3
10 files changed, 16 insertions, 17 deletions
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index acc9356ed..7349fb989 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -496,7 +496,7 @@ handle_address_list (void *cls,
return; /* was canceled */
memset (&allzeros, '\0', sizeof(allzeros));
- if ((0 == GNUNET_is_zero (&pi->peer)) &&
+ if ((GNUNET_YES == GNUNET_is_zero (&pi->peer)) &&
(0 == plugin_name_length) &&
(0 == plugin_address_length))
{
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index e8a95c65e..3cd831a39 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -685,7 +685,7 @@ GAS_handle_request_address_list (struct GNUNET_SERVICE_Client *client,
memset (&allzeros,
'\0',
sizeof(struct GNUNET_PeerIdentity));
- if (0 == GNUNET_is_zero (&alrm->peer))
+ if (GNUNET_YES == GNUNET_is_zero (&alrm->peer))
{
/* Return addresses for all peers */
GAS_addresses_get_peer_info (NULL,
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index a2068b31b..221364c5d 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -245,7 +245,7 @@ GCP_2s (const struct CadetPeer *cp)
char *ret;
if ((NULL == cp) ||
- (0 == GNUNET_is_zero (&cp->pid.public_key)))
+ (GNUNET_YES == GNUNET_is_zero (&cp->pid.public_key)))
return "NULL";
ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&cp->pid.public_key);
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index b2f99cd55..fcaae1026 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -1173,9 +1173,9 @@ GNUNET_memcmp_ct_ (const void *b1,
* @param a pointer to @a n bytes which should be tested for the
* entire memory being zero'ed out.
* @param n number of bytes in @a to be tested
- * @return 0 if a is zero, non-zero otherwise
+ * @return GNUNET_YES if a is zero, GNUNET_NO otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_is_zero_ (const void *a,
size_t n);
@@ -1185,7 +1185,7 @@ GNUNET_is_zero_ (const void *a,
*
* @param a pointer to a struct which should be tested for the
* entire memory being zero'ed out.
- * @return 0 if a is zero, non-zero otherwise
+ * @return GNUNET_YES if a is zero, GNUNET_NO otherwise
*/
#define GNUNET_is_zero(a) \
GNUNET_is_zero_ (a, sizeof (*a))
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index bb8138e23..b24bb2952 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -1809,7 +1809,7 @@ run_zone_iteration_round (struct ZoneIteration *zi, uint64_t limit)
start = GNUNET_TIME_absolute_get ();
GNUNET_break (GNUNET_SYSERR !=
GSN_database->iterate_records (GSN_database->cls,
- (0 == GNUNET_is_zero (&zi->zone))
+ (GNUNET_YES == GNUNET_is_zero (&zi->zone))
? NULL
: &zi->zone,
zi->seq,
@@ -2083,7 +2083,7 @@ monitor_iteration_next (void *cls)
else
zm->iteration_cnt = zm->limit; /* use it all */
ret = GSN_database->iterate_records (GSN_database->cls,
- (0 == GNUNET_is_zero (&zm->zone))
+ (GNUNET_YES == GNUNET_is_zero (&zm->zone))
? NULL
: &zm->zone,
zm->seq,
diff --git a/src/namestore/namestore_api_monitor.c b/src/namestore/namestore_api_monitor.c
index ab6140328..9dc955544 100644
--- a/src/namestore/namestore_api_monitor.c
+++ b/src/namestore/namestore_api_monitor.c
@@ -139,7 +139,7 @@ check_result (void *cls, const struct RecordResultMessage *lrm)
(void) cls;
if ((0 != GNUNET_memcmp (&lrm->private_key, &zm->zone)) &&
- (0 != GNUNET_is_zero (&zm->zone)))
+ (GNUNET_NO == GNUNET_is_zero (&zm->zone)))
{
GNUNET_break (0);
return GNUNET_SYSERR;
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index baefdfa88..2f6e17f3b 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -3209,7 +3209,7 @@ notify_monitors (const struct GNUNET_PeerIdentity *peer,
continue;
if (tc->details.monitor.one_shot)
continue;
- if ((0 != GNUNET_is_zero (&tc->details.monitor.peer)) &&
+ if ((GNUNET_NO == GNUNET_is_zero (&tc->details.monitor.peer)) &&
(0 != GNUNET_memcmp (&tc->details.monitor.peer, peer)))
continue;
notify_monitor (tc, peer, address, nt, me);
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c
index 4aad49777..a404a1627 100644
--- a/src/util/common_allocation.c
+++ b/src/util/common_allocation.c
@@ -538,9 +538,9 @@ GNUNET_copy_message (const struct GNUNET_MessageHeader *msg)
* @param a pointer to @a n bytes which should be tested for the
* entire memory being zero'ed out.
* @param n number of bytes in @a to be tested
- * @return 0 if a is zero, non-zero otherwise
+ * @return GNUNET_YES if a is zero, GNUNET_NO otherwise
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_is_zero_ (const void *a,
size_t n)
{
@@ -548,8 +548,8 @@ GNUNET_is_zero_ (const void *a,
for (size_t i = 0; i < n; i++)
if (b[i])
- return 1;
- return 0;
+ return GNUNET_NO;
+ return GNUNET_YES;
}
diff --git a/src/util/service.c b/src/util/service.c
index e6bbe855f..ddd31181d 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -473,7 +473,7 @@ check_ipv6_listed (const struct GNUNET_STRINGS_IPv6NetworkPolicy *list,
return GNUNET_NO;
i = 0;
NEXT:
- while (0 != GNUNET_is_zero (&list[i].network))
+ while (GNUNET_NO == GNUNET_is_zero (&list[i].network))
{
for (unsigned int j = 0; j < sizeof(struct in6_addr) / sizeof(int); j++)
if (((((int *) ip)[j] & ((int *) &list[i].netmask)[j])) !=
diff --git a/src/util/test_peer.c b/src/util/test_peer.c
index 320746c76..bb0bc48dc 100644
--- a/src/util/test_peer.c
+++ b/src/util/test_peer.c
@@ -106,8 +106,7 @@ check ()
* is expected to be set to zero
*/GNUNET_log_skip (1, GNUNET_YES);
GNUNET_PEER_resolve (0, &res);
- GNUNET_assert (0 ==
- GNUNET_is_zero (&res));
+ GNUNET_assert (GNUNET_YES == GNUNET_is_zero (&res));
/* Removing peer entries 1 and 3 from table using the list decrement function */
/* If count = 0, nothing should be done whatsoever */