<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12879">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">get_value_string(): guard against NULL<br><br>get_value_string() conveniently prints the value number to a static buffer if<br>it is unknown in a value_string array. Do the same if the value_string array<br>pointer itself is NULL.<br><br>To add osmo_use_count API (upcoming patch), I want to use a user supplied value<br>string array, and in its absence would like to just print the user enum value<br>as digits. I could add a separate NULL check around calling get_value_string(),<br>but by making get_value_string() itself guard against NULL, I can avoid<br>defining yet another static char buffer.<br><br>Change-Id: Ie640e9258a959da8f4f9089478de993509853997<br>---<br>M src/utils.c<br>1 file changed, 3 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/79/12879/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/utils.c b/src/utils.c</span><br><span>index 0b2ed31..2d5bcb0 100644</span><br><span>--- a/src/utils.c</span><br><span>+++ b/src/utils.c</span><br><span>@@ -73,6 +73,9 @@</span><br><span> {</span><br><span>   int i;</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+    if (!vs)</span><br><span style="color: hsl(120, 100%, 40%);">+              return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>       for (i = 0;; i++) {</span><br><span>          if (vs[i].value == 0 && vs[i].str == NULL)</span><br><span>                   break;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12879">change 12879</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/12879"/><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: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ie640e9258a959da8f4f9089478de993509853997 </div>
<div style="display:none"> Gerrit-Change-Number: 12879 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>