<p><a href="https://gerrit.osmocom.org/13121">View Change</a></p><p>1 comment:</p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0;"><p><a href="https://gerrit.osmocom.org/#/c/13121/5/include/osmocom/core/use_count.h">File include/osmocom/core/use_count.h:</a></p><ul style="list-style: none; padding: 0;"><li style="margin: 0; padding: 0 0 0 16px;"><p style="margin-bottom: 4px;"><a href="https://gerrit.osmocom.org/#/c/13121/5/include/osmocom/core/use_count.h@154">Patch Set #5, Line 154:</a> </p><p><blockquote style="border-left: 1px solid #aaa; margin: 10px 0; padding: 0 10px;"><pre style="font-family: monospace,monospace; white-space: pre-wrap;">*             foo_get(foo, "bar");       // one osmo_use_count_entry was allocated<br> *             foo_get(foo, "baz");       // a second osmo_use_count_entry was allocated<br> *             foo_get(foo, "baz");       // still two entries<br> *<br> *             printf("use: %s\n", osmo_use_count_name_buf(namebuf, sizeof(namebuf), &foo->use_count));<br> *             // "use: 3 (bar,2*baz)"<br> *<br> *             foo_put(foo, "bar");       // still two entries, one entry is idle ("bar"=0)<br> *             foo_put(foo, "baz");<br></pre></blockquote></p><p style="white-space: pre-wrap; word-wrap: break-word;">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.</p></li></ul></li></ul><p>To view, visit <a href="https://gerrit.osmocom.org/13121">change 13121</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/13121"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: comment </div>
<div style="display:none"> Gerrit-Change-Id: Ife31e6798b4e728a23913179e346552a7dd338c0 </div>
<div style="display:none"> Gerrit-Change-Number: 13121 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Harald Welte <laforge@gnumonks.org> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder (1000002) </div>
<div style="display:none"> Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Vadim Yanitskiy <axilirator@gmail.com> </div>
<div style="display:none"> Gerrit-CC: Max <msuraev@sysmocom.de> </div>
<div style="display:none"> Gerrit-Comment-Date: Sat, 16 Mar 2019 08:01:48 +0000 </div>
<div style="display:none"> Gerrit-HasComments: Yes </div>
<div style="display:none"> Gerrit-HasLabels: No </div>