https://projects.osmocom.org/https://projects.osmocom.org/favicon.ico?16647414092019-08-15T01:03:02ZOpen Source Mobile Communicationslibosmocore - Bug #4152: osmo_tdef_get() has API doc that encourages to pass -1 to an unsigned long argument, and promises certain behavior in case of -1 being passedhttps://projects.osmocom.org/issues/4152?journal_id=156082019-08-15T01:03:02Zneelsnhofmeyr@sysmocom.de
<ul></ul><p>I just noticed this patch merged recently:<br /><a class="external" href="https://git.osmocom.org/libosmocore/commit/?id=cfd6ac646224c59fc3f46c9e4ef9f7fecb6c1407">https://git.osmocom.org/libosmocore/commit/?id=cfd6ac646224c59fc3f46c9e4ef9f7fecb6c1407</a></p>
<pre>
commit cfd6ac646224c59fc3f46c9e4ef9f7fecb6c1407
Author: Harald Welte <laforge@gnumonks.org>
Date: Sun Jul 21 09:22:19 2019 +0200
tdef: remove bogus OSMO_ASSERT(unsigned long >= 0)
Change-Id: I7a544d2d43b83135def296674f777e48fe5fd80a
Closes: CID#190866
diff --git a/src/tdef.c b/src/tdef.c
index 9d5d7363..3cfb17c0 100644
--- a/src/tdef.c
+++ b/src/tdef.c
@@ -187,7 +187,6 @@ unsigned long osmo_tdef_get(const struct osmo_tdef *tdefs, int T, enum osmo_tdef
{
const struct osmo_tdef *t = osmo_tdef_get_entry((struct osmo_tdef*)tdefs, T);
if (!t) {
- OSMO_ASSERT(val_if_not_present >= 0);
return val_if_not_present;
}
return osmo_tdef_round(t->val, t->unit, as_unit);
</pre>
<p>And looking at the libosmocore patch <a class="external" href="https://gerrit.osmocom.org/c/libosmocore/+/12717/1">https://gerrit.osmocom.org/c/libosmocore/+/12717/1</a> the 'unsigned long' arg had crept in already in the first patch set.<br />I believe the better way would be to re-add the assertion and change the argument to a long, to again match the API doc and what osmo-bsc expects to happen.</p>
<p>See <a class="external" href="https://gerrit.osmocom.org/c/libosmocore/+/15218">https://gerrit.osmocom.org/c/libosmocore/+/15218</a></p> libosmocore - Bug #4152: osmo_tdef_get() has API doc that encourages to pass -1 to an unsigned long argument, and promises certain behavior in case of -1 being passedhttps://projects.osmocom.org/issues/4152?journal_id=156092019-08-15T01:05:28Zneelsnhofmeyr@sysmocom.de
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>In Progress</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>90</i></li></ul> libosmocore - Bug #4152: osmo_tdef_get() has API doc that encourages to pass -1 to an unsigned long argument, and promises certain behavior in case of -1 being passedhttps://projects.osmocom.org/issues/4152?journal_id=156102019-08-15T01:05:35Zneelsnhofmeyr@sysmocom.de
<ul><li><strong>Assignee</strong> set to <i>neels</i></li></ul> libosmocore - Bug #4152: osmo_tdef_get() has API doc that encourages to pass -1 to an unsigned long argument, and promises certain behavior in case of -1 being passedhttps://projects.osmocom.org/issues/4152?journal_id=159962019-09-17T11:20:46Zpespin
<ul></ul><p><a class="user active" href="https://projects.osmocom.org/users/91">neels</a> I think this ticket can be closed.</p> libosmocore - Bug #4152: osmo_tdef_get() has API doc that encourages to pass -1 to an unsigned long argument, and promises certain behavior in case of -1 being passedhttps://projects.osmocom.org/issues/4152?journal_id=160022019-09-17T14:04:18Zneelsnhofmeyr@sysmocom.de
<ul><li><strong>Status</strong> changed from <i>In Progress</i> to <i>Resolved</i></li><li><strong>% Done</strong> changed from <i>90</i> to <i>100</i></li></ul>