View Issue Details

IDProjectCategoryView StatusLast Update
0006475GNUnetutil librarypublic2020-08-15 05:12
ReporterFlorian Dold Assigned Toschanzen  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Target Version0.13.2Fixed in Version0.13.2 
Summary0006475: GNUNET_is_zero is a dangerously bad name
DescriptionA function that has "is" in the name would usually be expected to return a boolean. However,

struct GNUNET_HashCode hc = {0};

if (GNUNET_is_zero (&hc))
  printf("good");
else
  printf("gotcha!");

actually prints "gotacha!".

I get where this is coming from (0 == memcmp (...)), but it's still bad.

Can we at least rename it to GNUNET_cmp_zero?

This has bitten me twice in unrelated places now.
TagsNo tags attached.

Activities

schanzen

2020-08-11 20:53

manager   ~0016588

IMO it should return "enum GNUNET_GenericReturnValue" and not int.
I also would have assumed that it would return != 0 on success. But it does not.
To me, either swapping the return values or using the enum is a viable solution.

schanzen

2020-08-12 09:43

manager   ~0016590

I changed the API in be3bbfb47..99f820453

schanzen

2020-08-14 12:04

manager   ~0016605

Closing as resolved since at least 0.13.2

Issue History

Date Modified Username Field Change
2020-08-11 17:36 Florian Dold New Issue
2020-08-11 20:53 schanzen Note Added: 0016588
2020-08-11 20:54 schanzen Assigned To => schanzen
2020-08-11 20:54 schanzen Status new => acknowledged
2020-08-12 09:43 schanzen Status acknowledged => resolved
2020-08-12 09:43 schanzen Resolution open => fixed
2020-08-12 09:43 schanzen Fixed in Version => 0.13.2
2020-08-12 09:43 schanzen Note Added: 0016590
2020-08-12 09:43 schanzen Target Version => 0.13.2
2020-08-14 12:04 schanzen Note Added: 0016605
2020-08-14 12:04 schanzen Status resolved => closed