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

2017-12-12 Thread Neels Hofmeyr

Patch Set 1:

stackoverflow has 

  #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : 
__FILE__)

which would iterate around in file paths for each log statement. compared to 
terminal output that's probably neglectable.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


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

2017-12-12 Thread Neels Hofmeyr

Patch Set 1:

"__BASE_FILE__

This macro expands to the name of the main input file, in the form of a C 
string constant. This is the source file that was specified on the command line 
of the preprocessor or C compiler.
"

So it's not related to stripping path elements. If we did something like 'cd 
$(srcdir); gcc -o $(builddir)/thing.o' the paths would go shorter. I'm not so 
sure on when __BASE_FILE__ != __FILE__, maybe we should go back to __FILE__?

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


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

2017-12-12 Thread Neels Hofmeyr

Patch Set 1:

> Why do we see ../../../ in the file names? We switched logging to
 > __BASE_FILE__ to avoid this on src vs.  build dir builds..

I have no idea, maybe __BASE_FILE__ isn't working out as expected? I build in 
this dir topology and usually see the long ../../ paths:

  ./src/osmo-foo/configure.ac
  ./make/osmo-foo/Makefile

Can confirm though that LOGP macros use __BASE_FILE__.

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr 
Gerrit-HasComments: No


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

2017-12-11 Thread Holger Freyther

Patch Set 1:

Why do we see ../../../ in the file names? We switched logging to __BASE_FILE__ 
to avoid this on src vs.  build dir builds..

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Holger Freyther 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


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

2017-12-10 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

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


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) [0x55563b81]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/lib/x86_64-linux-gnu/libdbi.so.1(_error_handler+0x99) [0x763f5c39]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/lib/x86_64-linux-gnu/libdbi.so.1(dbi_result_next_row+0x3d) [0x763f785d]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0x11172) [0x55565172]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0x1e6bc) [0x555726bc]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0x1e7f6) [0x555727f6]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0x1f1d2) [0x555731d2]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0xbb86) [0xfb86]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x75cfe561]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0xbfba) [0xffba]

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

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald 

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

2017-12-10 Thread Harald Welte

Patch Set 1: Code-Review+2

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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


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

2017-12-10 Thread Neels Hofmeyr

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) [0x55563b81]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/lib/x86_64-linux-gnu/libdbi.so.1(_error_handler+0x99) [0x763f5c39]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/lib/x86_64-linux-gnu/libdbi.so.1(dbi_result_next_row+0x3d) [0x763f785d]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0x11172) [0x55565172]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0x1e6bc) [0x555726bc]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0x1e7f6) [0x555727f6]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0x1f1d2) [0x555731d2]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0xbb86) [0xfb86]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x75cfe561]
  DDB <000d> ../../../src/libosmocore/src/backtrace.c:57
/usr/local/bin/osmo-msc(+0xbfba) [0xffba]

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