Re: [Xenomai-core] [patch] problems with nucleus/types.h
Jan Kiszka wrote: Hi, after the latest changes in include/nucleus/types.h, I get some warnings during userspace lib compilation on my box: In file included from /usr/src/xenomai/include/nucleus/queue.h:24, from /usr/src/xenomai/include/nucleus/timer.h:24, from /usr/src/xenomai/include/nucleus/thread.h:24, from /usr/src/xenomai/skins/native/lib/../../native/task.h:27, from /usr/src/xenomai/skins/native/lib/timer.c:21: /usr/src/xenomai/include/nucleus/types.h: In function 'xnobject_create_name': /usr/src/xenomai/include/nucleus/types.h:99: warning: implicit declaration of function 'snprintf' /usr/src/xenomai/include/nucleus/types.h:99: warning: incompatible implicit declaration of built-in function 'snprintf' This is due to the static inline definition of xnobject_create_name in the mentioned header and missing a snprintf prototype in userspace. What about the attached patch? It also avoids duplicating code by using strncpy (or am I overseeing a specific reason for doing it the other way?). Applied, since types.h must be usable with as little deps as possible in order to grab types and definitions. Thanks. Jan Index: include/nucleus/types.h === --- include/nucleus/types.h (revision 54) +++ include/nucleus/types.h (working copy) @@ -76,26 +76,16 @@ #define XNOBJECT_NAME_LEN 32 -static inline void xnobject_copy_name (char *dst, - const char *src) -{ -if (src) - { - const char *rp = src; - char *wp = dst; - do - *wp++ = *rp; - while (*rp && rp++ - src < XNOBJECT_NAME_LEN); - } -else - *dst = '\0'; -} +#define xnobject_copy_name(dst, src) \ +do { \ +if (src) \ +strncpy(dst, src, XNOBJECT_NAME_LEN); \ +else \ +*dst = '\0'; \ +} while (0) -static inline int xnobject_create_name( - char *dst, size_t n, void *obj) -{ -return snprintf(dst, n, "%p", obj); -} +#define xnobject_create_name(dst, n, obj) \ +snprintf(dst, n, "%p", obj) #define minval(a,b) ((a) < (b) ? (a) : (b)) #define maxval(a,b) ((a) > (b) ? (a) : (b)) ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core -- Philippe.
Re: [Xenomai-core] [patch] problems with nucleus/types.h
Jan Kiszka wrote: Hi, after the latest changes in include/nucleus/types.h, I get some warnings during userspace lib compilation on my box: In file included from /usr/src/xenomai/include/nucleus/queue.h:24, from /usr/src/xenomai/include/nucleus/timer.h:24, from /usr/src/xenomai/include/nucleus/thread.h:24, from /usr/src/xenomai/skins/native/lib/../../native/task.h:27, from /usr/src/xenomai/skins/native/lib/timer.c:21: /usr/src/xenomai/include/nucleus/types.h: In function 'xnobject_create_name': /usr/src/xenomai/include/nucleus/types.h:99: warning: implicit declaration of function 'snprintf' /usr/src/xenomai/include/nucleus/types.h:99: warning: incompatible implicit declaration of built-in function 'snprintf' This is due to the static inline definition of xnobject_create_name in the mentioned header and missing a snprintf prototype in userspace. What about the attached patch? It also avoids duplicating code by using strncpy (or am I overseeing a specific reason for doing it the other way?). Applied, since types.h must be usable with as little deps as possible in order to grab types and definitions. Thanks. Jan Index: include/nucleus/types.h === --- include/nucleus/types.h (revision 54) +++ include/nucleus/types.h (working copy) @@ -76,26 +76,16 @@ #define XNOBJECT_NAME_LEN 32 -static inline void xnobject_copy_name (char *dst, - const char *src) -{ -if (src) - { - const char *rp = src; - char *wp = dst; - do - *wp++ = *rp; - while (*rp && rp++ - src < XNOBJECT_NAME_LEN); - } -else - *dst = '\0'; -} +#define xnobject_copy_name(dst, src) \ +do { \ +if (src) \ +strncpy(dst, src, XNOBJECT_NAME_LEN); \ +else \ +*dst = '\0'; \ +} while (0) -static inline int xnobject_create_name( - char *dst, size_t n, void *obj) -{ -return snprintf(dst, n, "%p", obj); -} +#define xnobject_create_name(dst, n, obj) \ +snprintf(dst, n, "%p", obj) #define minval(a,b) ((a) < (b) ? (a) : (b)) #define maxval(a,b) ((a) > (b) ? (a) : (b)) ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core -- Philippe. ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core
[Xenomai-core] [patch] problems with nucleus/types.h
Hi, after the latest changes in include/nucleus/types.h, I get some warnings during userspace lib compilation on my box: In file included from /usr/src/xenomai/include/nucleus/queue.h:24, from /usr/src/xenomai/include/nucleus/timer.h:24, from /usr/src/xenomai/include/nucleus/thread.h:24, from /usr/src/xenomai/skins/native/lib/../../native/task.h:27, from /usr/src/xenomai/skins/native/lib/timer.c:21: /usr/src/xenomai/include/nucleus/types.h: In function 'xnobject_create_name': /usr/src/xenomai/include/nucleus/types.h:99: warning: implicit declaration of function 'snprintf' /usr/src/xenomai/include/nucleus/types.h:99: warning: incompatible implicit declaration of built-in function 'snprintf' This is due to the static inline definition of xnobject_create_name in the mentioned header and missing a snprintf prototype in userspace. What about the attached patch? It also avoids duplicating code by using strncpy (or am I overseeing a specific reason for doing it the other way?). Jan Index: include/nucleus/types.h === --- include/nucleus/types.h (revision 54) +++ include/nucleus/types.h (working copy) @@ -76,26 +76,16 @@ #define XNOBJECT_NAME_LEN 32 -static inline void xnobject_copy_name (char *dst, - const char *src) -{ -if (src) - { - const char *rp = src; - char *wp = dst; - do - *wp++ = *rp; - while (*rp && rp++ - src < XNOBJECT_NAME_LEN); - } -else - *dst = '\0'; -} +#define xnobject_copy_name(dst, src) \ +do { \ +if (src) \ +strncpy(dst, src, XNOBJECT_NAME_LEN); \ +else \ +*dst = '\0'; \ +} while (0) -static inline int xnobject_create_name( - char *dst, size_t n, void *obj) -{ -return snprintf(dst, n, "%p", obj); -} +#define xnobject_create_name(dst, n, obj) \ +snprintf(dst, n, "%p", obj) #define minval(a,b) ((a) < (b) ? (a) : (b)) #define maxval(a,b) ((a) > (b) ? (a) : (b)) signature.asc Description: OpenPGP digital signature
[Xenomai-core] [patch] problems with nucleus/types.h
Hi, after the latest changes in include/nucleus/types.h, I get some warnings during userspace lib compilation on my box: In file included from /usr/src/xenomai/include/nucleus/queue.h:24, from /usr/src/xenomai/include/nucleus/timer.h:24, from /usr/src/xenomai/include/nucleus/thread.h:24, from /usr/src/xenomai/skins/native/lib/../../native/task.h:27, from /usr/src/xenomai/skins/native/lib/timer.c:21: /usr/src/xenomai/include/nucleus/types.h: In function 'xnobject_create_name': /usr/src/xenomai/include/nucleus/types.h:99: warning: implicit declaration of function 'snprintf' /usr/src/xenomai/include/nucleus/types.h:99: warning: incompatible implicit declaration of built-in function 'snprintf' This is due to the static inline definition of xnobject_create_name in the mentioned header and missing a snprintf prototype in userspace. What about the attached patch? It also avoids duplicating code by using strncpy (or am I overseeing a specific reason for doing it the other way?). Jan Index: include/nucleus/types.h === --- include/nucleus/types.h (revision 54) +++ include/nucleus/types.h (working copy) @@ -76,26 +76,16 @@ #define XNOBJECT_NAME_LEN 32 -static inline void xnobject_copy_name (char *dst, - const char *src) -{ -if (src) - { - const char *rp = src; - char *wp = dst; - do - *wp++ = *rp; - while (*rp && rp++ - src < XNOBJECT_NAME_LEN); - } -else - *dst = '\0'; -} +#define xnobject_copy_name(dst, src) \ +do { \ +if (src) \ +strncpy(dst, src, XNOBJECT_NAME_LEN); \ +else \ +*dst = '\0'; \ +} while (0) -static inline int xnobject_create_name( - char *dst, size_t n, void *obj) -{ -return snprintf(dst, n, "%p", obj); -} +#define xnobject_create_name(dst, n, obj) \ +snprintf(dst, n, "%p", obj) #define minval(a,b) ((a) < (b) ? (a) : (b)) #define maxval(a,b) ((a) > (b) ? (a) : (b)) signature.asc Description: OpenPGP digital signature ___ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core