path: root/include/osmocom
diff options
authorNeels Hofmeyr <neels@hofmeyr.de>2019-08-15 02:52:55 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2019-08-15 03:02:34 +0200
commit989f01c4065d3d3f83562b20a2a2b79189cb81f2 (patch)
tree80450370a1b2e1e94db19ff81999cd3646af208f /include/osmocom
parentd0b3b9edac978c91bf84aa2537aa24426685b1fb (diff)
osmo_tdef_get(): allow passing -1 as default timeoutneels/tdef
The intention of osmo_tdef_get()'s val_if_not_present argument was to return a default timeout, or to optionally abort the program for missing timer definitions if the default timeout is < 0. This was the case in the original implementation of this API in osmo-bsc, but in the migration to libosmocore, the argument was by accident changed to an unsigned type. In consequence, the assertion in the implementation that was intended to abort the program seemed bogus to coverity, and was fixed by removal in I7a544d2d43b83135def296674f777e48fe5fd80a -- the wrong direction, as is obvious from the API doc for osmo_tdef_get(). Note that osmo-bsc master passes -1 in various places and expects the program-abort behavior that was missing from the libosmocore implementation. Change the val_if_not_present argument to a signed type, and revert removal of the assertion, so that passing -1 has the effect described in the API doc: program abort on missing timer definition. This bug was not detected because it is hard to write tests that expect a program abort to happen, hence no tests for this API feature exist. Related: OS#4152 Change-Id: Ie61c3c85069916336e6dbd91a2c16f7634816417
Diffstat (limited to 'include/osmocom')
1 files changed, 1 insertions, 1 deletions
diff --git a/include/osmocom/core/tdef.h b/include/osmocom/core/tdef.h
index c8d9053d..566f5dd3 100644
--- a/include/osmocom/core/tdef.h
+++ b/include/osmocom/core/tdef.h
@@ -95,7 +95,7 @@ struct osmo_tdef {
void osmo_tdefs_reset(struct osmo_tdef *tdefs);
unsigned long osmo_tdef_get(const struct osmo_tdef *tdefs, int T, enum osmo_tdef_unit as_unit,
- unsigned long val_if_not_present);
+ long val_if_not_present);
struct osmo_tdef *osmo_tdef_get_entry(struct osmo_tdef *tdefs, int T);
/*! Using osmo_tdef for osmo_fsm_inst: array entry for a mapping of state numbers to timeout definitions.