Browse Source

fix: GNUNET_is_zero(ptr) should return enum GNUNET_GenericReturnValue. Fixes #6475.

Martin Schanzenbach 3 years ago
parent
commit
99f8204531

+ 1 - 1
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))
   {

+ 1 - 1
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,

+ 1 - 1
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);

+ 3 - 3
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))

+ 2 - 2
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,

+ 1 - 1
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;

+ 1 - 1
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);

+ 4 - 4
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;
 }
 
 

+ 1 - 1
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])) !=

+ 1 - 2
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 */