Module: xenomai-3
Branch: master
Commit: 12fa18f4267cc67882d477b282eb72b2daa5c193
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=12fa18f4267cc67882d477b282eb72b2daa5c193

Author: Ronny Meeus <ronny.me...@gmail.com>
Date:   Tue Nov 29 14:26:00 2016 +0100

boilerplate: solve compiler warning when libgen.h is included

In boilerplate function 'get_program_name', basename is used.

When libgen.h is included in your program, the basename gets the POSIX
version (no const char*, see 'man basename'): char *basename(char
*path);

This results in the following compiler warning:
boilerplate/setup.h: In function 'const char* get_program_name()':
boilerplate/setup.h:107: error: invalid conversion from 'const char*' to 'char*'
boilerplate/setup.h:107: error:   initializing argument 1 of 'char* 
__xpg_basename(char*)'

Test application:

int main(int argc, char * const argv[])
{
  return 0;
}

When the libgen.h is not included, the warning is not seen.

This patch solve the above issue by moving the implementation to setup.c
instead of using an inline function.

---

 include/boilerplate/setup.h |    5 +----
 lib/boilerplate/setup.c     |    5 +++++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/boilerplate/setup.h b/include/boilerplate/setup.h
index 5a18f6a..374758b 100644
--- a/include/boilerplate/setup.h
+++ b/include/boilerplate/setup.h
@@ -102,10 +102,7 @@ extern int __config_done;
 
 extern struct base_setup_data __base_setup_data;
 
-static inline const char *get_program_name(void)
-{
-       return basename(__base_setup_data.arg0 ?: "program");
-}
+const char *get_program_name(void);
 
 void __trace_me(const char *fmt, ...);
 
diff --git a/lib/boilerplate/setup.c b/lib/boilerplate/setup.c
index dbeb5e1..f1760e6 100644
--- a/lib/boilerplate/setup.c
+++ b/lib/boilerplate/setup.c
@@ -644,3 +644,8 @@ void __register_setup_call(struct setup_descriptor *p, int 
id)
        }
        pvlist_prepend(&p->__reserved.next, &setup_list);
 }
+
+const char *get_program_name(void)
+{
+       return basename(__base_setup_data.arg0 ?: "program");
+}


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to