[PATCH] osmo-msc[master]: sms.db: silence libdbi warnings on out-of-range index

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
Sun Dec 10 13:51:13 UTC 2017


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

sms.db: silence libdbi warnings on out-of-range index

Apparently, since libdbi 0.9.0 aka 0.9.0-5 on debian-testing, osmo-msc barfs
numerous libdbi warnings whenever a query rightfully returns no rows.

Trivially query whether there are any rows first by adding an inline wrap
function next_row().

Silenced:

  DDB <000d> ../../../../src/osmo-msc/src/libmsc/db.c:188 DBI: -6: An invalid or out-of-range index was passed to libdbi
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:47 backtrace() returned 11 addresses
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0xfb81) [0x555555563b81]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/lib/x86_64-linux-gnu/libdbi.so.1(_error_handler+0x99) [0x7ffff63f5c39]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/lib/x86_64-linux-gnu/libdbi.so.1(dbi_result_next_row+0x3d) [0x7ffff63f785d]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0x11172) [0x555555565172]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0x1e6bc) [0x5555555726bc]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0x1e7f6) [0x5555555727f6]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0x1f1d2) [0x5555555731d2]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0xbb86) [0x55555555fb86]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7ffff5cfe561]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57        /usr/local/bin/osmo-msc(+0xbfba) [0x55555555ffba]

Related: OS#2667
Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
---
M src/libmsc/db.c
1 file changed, 14 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/65/5265/1

diff --git a/src/libmsc/db.c b/src/libmsc/db.c
index eba4b1b..0104bce 100644
--- a/src/libmsc/db.c
+++ b/src/libmsc/db.c
@@ -181,6 +181,13 @@
 		")",
 };
 
+static inline int next_row(dbi_result result)
+{
+	if (!dbi_result_has_next_row(result))
+		return 0;
+	return dbi_result_next_row(result);
+}
+
 void db_error_func(dbi_conn conn, void *data)
 {
 	const char *msg;
@@ -318,7 +325,7 @@
 		     "Failed fetch messages from the old SMS table (upgrade from rev 3).\n");
 		goto rollback;
 	}
-	while (dbi_result_next_row(result)) {
+	while (next_row(result)) {
 		sms = sms_from_result_v3(result);
 		if (db_sms_store(sms) != 0) {
 			LOGP(DDB, LOGL_ERROR, "Failed to store message to the new SMS table(upgrade from rev 3).\n");
@@ -464,7 +471,7 @@
 		     "Failed fetch messages from the old SMS table (upgrade from rev 4).\n");
 		goto rollback;
 	}
-	while (dbi_result_next_row(result)) {
+	while (next_row(result)) {
 		sms = sms_from_result_v4(result);
 		if (db_sms_store(sms) != 0) {
 			LOGP(DDB, LOGL_ERROR, "Failed to store message to the new SMS table(upgrade from rev 4).\n");
@@ -540,7 +547,7 @@
 	if (!result)
 		return -EINVAL;
 
-	if (!dbi_result_next_row(result)) {
+	if (!next_row(result)) {
 		dbi_result_free(result);
 		return -EINVAL;
 	}
@@ -787,7 +794,7 @@
 	if (!result)
 		return NULL;
 
-	if (!dbi_result_next_row(result)) {
+	if (!next_row(result)) {
 		dbi_result_free(result);
 		return NULL;
 	}
@@ -817,7 +824,7 @@
 	if (!result)
 		return NULL;
 
-	if (!dbi_result_next_row(result)) {
+	if (!next_row(result)) {
 		dbi_result_free(result);
 		return NULL;
 	}
@@ -858,7 +865,7 @@
 	if (!result)
 		return NULL;
 
-	if (!dbi_result_next_row(result)) {
+	if (!next_row(result)) {
 		dbi_result_free(result);
 		return NULL;
 	}
@@ -891,7 +898,7 @@
 	if (!result)
 		return NULL;
 
-	if (!dbi_result_next_row(result)) {
+	if (!next_row(result)) {
 		dbi_result_free(result);
 		return NULL;
 	}

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

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



More information about the gerrit-log mailing list