Change in libosmocore[master]: add osmo_use_count API

Harald Welte gerrit-no-reply at
Sat Mar 16 08:01:48 UTC 2019

Harald Welte has posted comments on this change. ( )

Change subject: add osmo_use_count API

Patch Set 5:

(1 comment)
File include/osmocom/core/use_count.h:
PS5, Line 154: *             foo_get(foo, "bar");       // one osmo_use_count_entry was allocated
             :  *             foo_get(foo, "baz");       // a second osmo_use_count_entry was allocated
             :  *             foo_get(foo, "baz");       // still two entries
             :  *
             :  *             printf("use: %s\n", osmo_use_count_name_buf(namebuf, sizeof(namebuf), &foo->use_count));
             :  *             // "use: 3 (bar,2*baz)"
             :  *
             :  *             foo_put(foo, "bar");       // still two entries, one entry is idle ("bar"=0)
             :  *             foo_put(foo, "baz");
I know this is just an example, but at least in any code that eveer uses this I strongly suggest to not use literal strings here, but have #defines for it.  The rationale is quite simple: If you have a typo in the enum, then it will give a compile-time failure.  If you have a typo in a literal string that you write dozens of time in your code, it is hard to spot by the human eye and the compiler will not warn/fail.  You will only see the error at runtime, which is the worst outcome.

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ife31e6798b4e728a23913179e346552a7dd338c0
Gerrit-Change-Number: 13121
Gerrit-PatchSet: 5
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at>
Gerrit-Reviewer: Harald Welte <laforge at>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at>
Gerrit-CC: Max <msuraev at>
Gerrit-Comment-Date: Sat, 16 Mar 2019 08:01:48 +0000
Gerrit-HasComments: Yes
Gerrit-HasLabels: No
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list