gbproxy: Add gbprox_clear_patch_filter() (Coverity)
Add a separate function to clear the IMSI filter to be used instead of
gbprox_set_patch_filter(cfg, NULL, ...). Albeit it fixes a Coverity
issue (Unchecked return value), it is a false positive, since the
return value is always 0 in these cases. Nevertheless it is more
obvious what happens when an explicit clear function is called. Using
NULL as filter argument of gbprox_set_patch_filter still clears the
filter.
Fixes: Coverity CID 1231255
Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index a8ce3cc..64fb55b 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -481,16 +481,21 @@
OSMO_ASSERT(llist_empty(&state->enabled_tllis));
}
+void gbprox_clear_patch_filter(struct gbproxy_config *cfg)
+{
+ if (cfg->check_imsi) {
+ regfree(&cfg->imsi_re_comp);
+ cfg->check_imsi = 0;
+ }
+}
+
int gbprox_set_patch_filter(struct gbproxy_config *cfg, const char *filter,
const char **err_msg)
{
static char err_buf[300];
int rc;
- if (cfg->check_imsi) {
- regfree(&cfg->imsi_re_comp);
- cfg->check_imsi = 0;
- }
+ gbprox_clear_patch_filter(cfg);
if (!filter)
return 0;