[PATCH] osmo-hlr[master]: hlr_db_tool: fix error log strerror invocation

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Tue Nov 7 12:22:37 UTC 2017


Review at  https://gerrit.osmocom.org/4713

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
---
M src/hlr_db_tool.c
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/13/4713/1

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;
 	}
 

-- 
To view, visit https://gerrit.osmocom.org/4713
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaab46f565a1112d8a7def8ea90a5cd440c0a3b41
Gerrit-PatchSet: 1
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list