<p>neels has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/20330">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">osmo_use_count_to_str: make robust against unused use_count<br><br>A use_count struct gets properly initialized once the first use count is added.<br>Normally, this happens directly at object allocation. Still make sure<br>osmo_use_count_to_str_*() don't crash on a yet unused struct use_count.<br><br>Change-Id: I47b1acc7f13f2557c78e2cbe67d4690709ce795e<br>---<br>M src/use_count.c<br>1 file changed, 5 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/30/20330/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/use_count.c b/src/use_count.c</span><br><span>index 738cc5d..d07e47f 100644</span><br><span>--- a/src/use_count.c</span><br><span>+++ b/src/use_count.c</span><br><span>@@ -127,6 +127,9 @@</span><br><span> </span><br><span>        OSMO_STRBUF_PRINTF(sb, "%" PRId32 " (", count);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+       if (!uc->use_counts.next)</span><br><span style="color: hsl(120, 100%, 40%);">+          goto uninitialized;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>        first = true;</span><br><span>        llist_for_each_entry(e, &uc->use_counts, entry) {</span><br><span>             if (!e->count)</span><br><span>@@ -140,6 +143,8 @@</span><br><span>      }</span><br><span>    if (first)</span><br><span>           OSMO_STRBUF_PRINTF(sb, "-");</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+uninitialized:</span><br><span>     OSMO_STRBUF_PRINTF(sb, ")");</span><br><span>       return sb.chars_needed;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/20330">change 20330</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/c/libosmocore/+/20330"/><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-Change-Id: I47b1acc7f13f2557c78e2cbe67d4690709ce795e </div>
<div style="display:none"> Gerrit-Change-Number: 20330 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>