fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/27012 )
Change subject: logging: fix printing of '\0' when filename printed last ......................................................................
logging: fix printing of '\0' when filename printed last
As was demonstrated in I54bf5e5c036efb1908232fe3d8e8e2989715fbb3, when the logging is configured to print the filename *after* the logging message, each logging line contains an artifact - '\0'.
The problem is that the 'len' variable is not updated. Fix this.
Change-Id: I5c920a0d5c1cf45bcdd327b39e33d63346b4f51c Fixes: I393907b3c9e0cc1145e102328adad0a83ee13a9f --- M src/logging.c M tests/logging/logging_test_wqueue.err 2 files changed, 2 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified
diff --git a/src/logging.c b/src/logging.c index 5336e53..1a0abc2 100644 --- a/src/logging.c +++ b/src/logging.c @@ -586,6 +586,7 @@ break; case LOG_FILENAME_PATH: offset--; + len--; ret = snprintf(buf + offset, rem, " (%s:%d)\n", file, line); if (ret < 0) goto err; @@ -593,6 +594,7 @@ break; case LOG_FILENAME_BASENAME: offset--; + len--; ret = snprintf(buf + offset, rem, " (%s:%d)\n", const_basename(file), line); if (ret < 0) goto err; diff --git a/tests/logging/logging_test_wqueue.err b/tests/logging/logging_test_wqueue.err index 3e2008b..01ab878 100644 --- a/tests/logging/logging_test_wqueue.err +++ b/tests/logging/logging_test_wqueue.err Binary files differ