[PATCH] osmo-hlr[master]: code undup: use db_bind_text() in db_get_auth_data()

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Wed Oct 11 20:32:29 UTC 2017


Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/4189

to look at the new patch set (#4).

code undup: use db_bind_text() in db_get_auth_data()

To make the db_bind_text() error reporting mention "imsi", change the
DB_STMT_AUC_BY_IMSI to use a named parameter.

Change-Id: I49bd5eb78170cf4cdf8abb386c766d20d9f1cf73
---
M src/db.c
M src/db_auc.c
2 files changed, 3 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-hlr refs/changes/89/4189/4

diff --git a/src/db.c b/src/db.c
index f1c14c9..fbf5c76 100644
--- a/src/db.c
+++ b/src/db.c
@@ -52,7 +52,7 @@
 		" FROM subscriber"
 		" LEFT JOIN auc_2g ON auc_2g.subscriber_id = subscriber.id"
 		" LEFT JOIN auc_3g ON auc_3g.subscriber_id = subscriber.id"
-		" WHERE imsi = ?",
+		" WHERE imsi = $imsi",
 	[DB_STMT_AUC_UPD_SQN] = "UPDATE auc_3g SET sqn = $sqn WHERE subscriber_id = $subscriber_id",
 	[DB_STMT_UPD_PURGE_CS_BY_IMSI] = "UPDATE subscriber SET ms_purged_cs = $val WHERE imsi = $imsi",
 	[DB_STMT_UPD_PURGE_PS_BY_IMSI] = "UPDATE subscriber SET ms_purged_ps = $val WHERE imsi = $imsi",
diff --git a/src/db_auc.c b/src/db_auc.c
index eae5070..7bbc93f 100644
--- a/src/db_auc.c
+++ b/src/db_auc.c
@@ -87,14 +87,8 @@
 	memset(aud2g, 0, sizeof(*aud2g));
 	memset(aud3g, 0, sizeof(*aud3g));
 
-	/* bind the IMSI value */
-	rc = sqlite3_bind_text(stmt, 1, imsi, -1,
-				SQLITE_STATIC);
-	if (rc != SQLITE_OK) {
-		LOGAUC(imsi, LOGL_ERROR, "Error binding IMSI: %d\n", rc);
-		ret = -EIO;
-		goto out;
-	}
+	if (!db_bind_text(stmt, "$imsi", imsi))
+		return -EIO;
 
 	/* execute the statement */
 	rc = sqlite3_step(stmt);

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I49bd5eb78170cf4cdf8abb386c766d20d9f1cf73
Gerrit-PatchSet: 4
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder


More information about the gerrit-log mailing list