hlr_db_tool: fix error log strerror invocation
The db API returns negative errno values, need to flip the sign before feeding
to strerror.
Fixes: coverity CID#178658
Change-Id: Iaab46f565a1112d8a7def8ea90a5cd440c0a3b41
diff --git a/src/hlr_db_tool.c b/src/hlr_db_tool.c
index 8982739..eb82c92 100644
--- a/src/hlr_db_tool.c
+++ b/src/hlr_db_tool.c
@@ -284,12 +284,12 @@
snprintf(imsi_str, sizeof(imsi_str), "%"PRId64, imsi);
rc = db_subscr_create(dbc, imsi_str);
- if (rc) {
+ if (rc < 0) {
LOGP(DDB, LOGL_ERROR, "OsmoNITB DB import to %s: failed to create IMSI %s: %d: %s\n",
dbc->fname,
imsi_str,
rc,
- strerror(rc));
+ strerror(-rc));
/* on error, still attempt to continue */
}
@@ -303,13 +303,13 @@
/* find the just created id */
rc = db_subscr_get_by_imsi(dbc, imsi_str, &subscr);
- if (rc) {
+ if (rc < 0) {
LOGP(DDB, LOGL_ERROR, "OsmoNITB DB import to %s: created IMSI %s,"
" but failed to get new subscriber id: %d: %s\n",
dbc->fname,
imsi_str,
rc,
- strerror(rc));
+ strerror(-rc));
return;
}