<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/17604">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">logging: use LOGL_NOTICE when not loglevel is set<br><br>when the API user of libosmocores logging infrastructure does not set a<br>pre-defined logging level in struct log_info_cat, the result would be an<br>invalid logging level. In order to avoid problems with that and to spare<br>all the additional .loglevel = LOGL_NOTICE (API users are advised to use<br>LOGL_NOTICE as default) lines in the user code lets check the logging<br>level on startup and set LOGL_NOTICE if there is no logging level set.<br><br>Change-Id: Ib9e180261505062505fc4605a98023910f76cde6<br>Related: OS#2577<br>---<br>M src/logging.c<br>1 file changed, 8 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/04/17604/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/logging.c b/src/logging.c</span><br><span>index 4d6224d..d67181c 100644</span><br><span>--- a/src/logging.c</span><br><span>+++ b/src/logging.c</span><br><span>@@ -1052,10 +1052,17 @@</span><br><span>                 return -ENOMEM;</span><br><span>      }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   if (inf) { /* copy over the user part */</span><br><span style="color: hsl(120, 100%, 40%);">+      /* copy over the user part and sanitize loglevel */</span><br><span style="color: hsl(120, 100%, 40%);">+   if (inf) {</span><br><span>           for (i = 0; i < inf->num_cat; i++) {</span><br><span>                   memcpy((struct log_info_cat *) &osmo_log_info->cat[i],</span><br><span>                               &inf->cat[i], sizeof(struct log_info_cat));</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+                   /* Make sure that the loglevel is set to NOTICE in case</span><br><span style="color: hsl(120, 100%, 40%);">+                        * no loglevel has been preset. */</span><br><span style="color: hsl(120, 100%, 40%);">+                    if (!osmo_log_info->cat[i].loglevel)</span><br><span style="color: hsl(120, 100%, 40%);">+                               *(uint8_t*) (&osmo_log_info->cat[i].loglevel) =</span><br><span style="color: hsl(120, 100%, 40%);">+                                    LOGL_NOTICE;</span><br><span>             }</span><br><span>    }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/17604">change 17604</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/+/17604"/><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: Ib9e180261505062505fc4605a98023910f76cde6 </div>
<div style="display:none"> Gerrit-Change-Number: 17604 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>