aboutsummaryrefslogtreecommitdiffstats
path: root/src/logging.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2022-01-29 20:34:45 +0600
committerfixeria <vyanitskiy@sysmocom.de>2022-01-31 16:56:09 +0000
commit83f423b11eebfcd3dd649ed43adf237e4e4875d9 (patch)
treebc50ef5ed34e33b78094aa9de5fbc2829d749e45 /src/logging.c
parent09d6574a457d3f06a372990b83311bbd4b98757c (diff)
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
Diffstat (limited to 'src/logging.c')
-rw-r--r--src/logging.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/logging.c b/src/logging.c
index 5336e538..1a0abc2f 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -586,6 +586,7 @@ static int _output_buf(char *buf, int buf_len, struct log_target *target, unsign
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 @@ static int _output_buf(char *buf, int buf_len, struct log_target *target, unsign
break;
case LOG_FILENAME_BASENAME:
offset--;
+ len--;
ret = snprintf(buf + offset, rem, " (%s:%d)\n", const_basename(file), line);
if (ret < 0)
goto err;