[libgpiod][PATCH 2/3] tools-common: fix build for Android

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



program_invocation_name doesn't exist in Android, getprogname() should
be used instead.

Signed-off-by: Gary Bisson <gary.bisson@xxxxxxxxxxxxxxxxxxx>
---
Hi,

I couldn't an equivalent to program_invocation_short_name, so the
program is now using program_invocation_name all the time, hope it's ok.

Regards,
Gary
---
 tools/tools-common.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/tools-common.c b/tools/tools-common.c
index 12bde20..1d7fc2c 100644
--- a/tools/tools-common.c
+++ b/tools/tools-common.c
@@ -21,7 +21,11 @@
 
 const char *get_progname(void)
 {
+#if defined __ANDROID__
+	return getprogname();
+#else
 	return program_invocation_name;
+#endif
 }
 
 void die(const char *fmt, ...)
@@ -29,7 +33,7 @@ void die(const char *fmt, ...)
 	va_list va;
 
 	va_start(va, fmt);
-	fprintf(stderr, "%s: ", program_invocation_name);
+	fprintf(stderr, "%s: ", get_progname());
 	vfprintf(stderr, fmt, va);
 	fprintf(stderr, "\n");
 	va_end(va);
@@ -42,7 +46,7 @@ void die_perror(const char *fmt, ...)
 	va_list va;
 
 	va_start(va, fmt);
-	fprintf(stderr, "%s: ", program_invocation_name);
+	fprintf(stderr, "%s: ", get_progname());
 	vfprintf(stderr, fmt, va);
 	fprintf(stderr, ": %s\n", strerror(errno));
 	va_end(va);
@@ -53,7 +57,7 @@ void die_perror(const char *fmt, ...)
 void print_version(void)
 {
 	printf("%s (libgpiod) v%s\n",
-	       program_invocation_short_name, gpiod_version_string());
+	       get_progname(), gpiod_version_string());
 	printf("Copyright (C) 2017-2018 Bartosz Golaszewski\n");
 	printf("License: LGPLv2.1\n");
 	printf("This is free software: you are free to change and redistribute it.\n");
-- 
2.26.2




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux