ConnMan network manager
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: connman@lists.linux.dev
Cc: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH] src/log.c: Include libgen.h for basename API
Date: Mon,  1 Jan 2024 17:53:30 -0800	[thread overview]
Message-ID: <20240102015330.3730946-1-raj.khem@gmail.com> (raw)

Use POSIX version of basename. This comes to front with latest musl
which dropped the declaration from string.h [1] it fails to build with
clang-17+ because it treats implicit function declaration as error.

Fix it by applying the basename on a copy of string since posix version
may modify the input string.

[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 src/log.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/log.c b/src/log.c
index 554b046..941e078 100644
--- a/src/log.c
+++ b/src/log.c
@@ -24,6 +24,7 @@
 #endif
 
 #include <stdio.h>
+#include <libgen.h>
 #include <unistd.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -196,6 +197,7 @@ int __connman_log_init(const char *program, const char *debug,
 		const char *program_name, const char *program_version)
 {
 	static char path[PATH_MAX];
+  char* tmp = strdup(program);
 	int option = LOG_NDELAY | LOG_PID;
 
 	program_exec = program;
@@ -212,8 +214,8 @@ int __connman_log_init(const char *program, const char *debug,
 	if (backtrace)
 		signal_setup(signal_handler);
 
-	openlog(basename(program), option, LOG_DAEMON);
-
+	openlog(basename(tmp), option, LOG_DAEMON);
+  free(tmp);
 	syslog(LOG_INFO, "%s version %s", program_name, program_version);
 
 	return 0;
-- 
2.43.0


             reply	other threads:[~2024-01-02  1:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02  1:53 Khem Raj [this message]
2024-01-15  7:53 ` [PATCH] src/log.c: Include libgen.h for basename API Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240102015330.3730946-1-raj.khem@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).