From 872037bb1437ab961f97834a624eb2d9b0706ab2 Mon Sep 17 00:00:00 2001 From: Pierre-Marc Fournier Date: Fri, 12 Jun 2009 13:59:45 -0400 Subject: [PATCH] start applying warning fixes from Jan Blunck --- libust/marker.h | 46 ++++++++++++++-------------- libust/relay.c | 8 ++--- libust/serialize.c | 2 +- libust/tracectl.c | 47 +++++++++++++++-------------- libust/tracepoint.h | 73 +++++++++++++++++++++++++-------------------- ust/ust.c | 3 +- 6 files changed, 95 insertions(+), 84 deletions(-) diff --git a/libust/marker.h b/libust/marker.h index 122fca7..3a86ac3 100644 --- a/libust/marker.h +++ b/libust/marker.h @@ -65,7 +65,8 @@ struct marker { void *tp_cb; /* Optional tracepoint callback */ } __attribute__((aligned(8))); -//ust// #ifdef CONFIG_MARKERS +#define CONFIG_MARKERS +#ifdef CONFIG_MARKERS #define _DEFINE_MARKER(channel, name, tp_name_str, tp_cb, format) \ static const char __mstrtab_##channel##_##name[] \ @@ -133,24 +134,24 @@ extern void marker_update_probe_range(struct marker *begin, #define GET_MARKER(channel, name) (__mark_##channel##_##name) -//ust// #else /* !CONFIG_MARKERS */ -//ust// #define DEFINE_MARKER(channel, name, tp_name, tp_cb, format) -//ust// #define __trace_mark(generic, channel, name, call_private, format, args...) \ -//ust// __mark_check_format(format, ## args) -//ust// #define __trace_mark_tp(channel, name, call_private, tp_name, tp_cb, \ -//ust// format, args...) \ -//ust// do { \ -//ust// void __check_tp_type(void) \ -//ust// { \ -//ust// register_trace_##tp_name(tp_cb); \ -//ust// } \ -//ust// __mark_check_format(format, ## args); \ -//ust// } while (0) -//ust// static inline void marker_update_probe_range(struct marker *begin, -//ust// struct marker *end) -//ust// { } -//ust// #define GET_MARKER(channel, name) -//ust// #endif /* CONFIG_MARKERS */ +#else /* !CONFIG_MARKERS */ +#define DEFINE_MARKER(channel, name, tp_name, tp_cb, format) +#define __trace_mark(generic, channel, name, call_private, format, args...) \ + __mark_check_format(format, ## args) +#define __trace_mark_tp(channel, name, call_private, tp_name, tp_cb, \ + format, args...) \ + do { \ + void __check_tp_type(void) \ + { \ + register_trace_##tp_name(tp_cb); \ + } \ + __mark_check_format(format, ## args); \ + } while (0) +static inline void marker_update_probe_range(struct marker *begin, + struct marker *end) +{ } +#define GET_MARKER(channel, name) +#endif /* CONFIG_MARKERS */ /** * trace_mark - Marker using code patching @@ -282,10 +283,11 @@ struct lib { struct list_head list; }; -int marker_register_lib(struct marker *markers_start, int markers_count); +extern int marker_register_lib(struct marker *markers_start, + int markers_count); -#define MARKER_LIB \ -extern struct marker __start___markers[] __attribute__((visibility("hidden"))); \ +#define MARKER_LIB \ +extern struct marker __start___markers[] __attribute__((visibility("hidden"))); \ extern struct marker __stop___markers[] __attribute__((visibility("hidden"))); \ \ static void __attribute__((constructor)) __markers__init(void) \ diff --git a/libust/relay.c b/libust/relay.c index 4c57424..27794f9 100644 --- a/libust/relay.c +++ b/libust/relay.c @@ -1537,7 +1537,7 @@ static void ltt_chan_alloc_ltt_buf(struct ltt_channel_struct *ltt_chan) result = ltt_chan->buf_shmid = shmget(getpid(), size, IPC_CREAT | IPC_EXCL | 0700); if(ltt_chan->buf_shmid == -1) { PERROR("shmget"); - return -1; + return; } ptr = shmat(ltt_chan->buf_shmid, NULL, 0); @@ -1552,12 +1552,12 @@ static void ltt_chan_alloc_ltt_buf(struct ltt_channel_struct *ltt_chan) result = shmctl(ltt_chan->buf_shmid, IPC_RMID, NULL); if(result == -1) { perror("shmctl"); - return -1; + return; } ltt_chan->buf = ptr; - return 0; + return; destroy_shmem: result = shmctl(ltt_chan->buf_shmid, IPC_RMID, NULL); @@ -1565,7 +1565,7 @@ static void ltt_chan_alloc_ltt_buf(struct ltt_channel_struct *ltt_chan) perror("shmctl"); } - return -1; + return; } /* diff --git a/libust/serialize.c b/libust/serialize.c index 00ba487..04ece91 100644 --- a/libust/serialize.c +++ b/libust/serialize.c @@ -676,7 +676,7 @@ notrace void ltt_vtrace(const struct marker *mdata, void *probe_data, /* Out-of-order commit */ ltt_commit_slot(channel, &transport_data, buf_offset, data_size, slot_size); - printf("just commited event at offset %d and size %d\n", buf_offset, slot_size); + printf("just commited event at offset %ld and size %zd\n", buf_offset, slot_size); } //ust// __get_cpu_var(ltt_nesting)--; ltt_nesting--; diff --git a/libust/tracectl.c b/libust/tracectl.c index e9907fc..b32b501 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include #include #include @@ -113,7 +114,7 @@ void notif_cb(void) } } -static int inform_consumer_daemon(void) +static void inform_consumer_daemon(void) { ustcomm_request_consumer(getpid(), "metadata"); ustcomm_request_consumer(getpid(), "ust"); @@ -148,7 +149,7 @@ void process_blocked_consumers(void) result = poll(fds, n_fds, 0); if(result == -1) { PERROR("poll"); - return -1; + return; } list_for_each_entry(bc, &blocked_consumers, list) { @@ -200,7 +201,7 @@ void process_blocked_consumers(void) } -int listener_main(void *p) +void *listener_main(void *p) { int result; @@ -252,19 +253,19 @@ int listener_main(void *p) result = ltt_trace_setup(trace_name); if(result < 0) { ERR("ltt_trace_setup failed"); - return; + return (void *)1; } result = ltt_trace_set_type(trace_name, trace_type); if(result < 0) { ERR("ltt_trace_set_type failed"); - return; + return (void *)1; } result = ltt_trace_alloc(trace_name); if(result < 0) { ERR("ltt_trace_alloc failed"); - return; + return (void *)1; } inform_consumer_daemon(); @@ -281,13 +282,13 @@ int listener_main(void *p) result = ltt_trace_setup(trace_name); if(result < 0) { ERR("ltt_trace_setup failed"); - return; + return (void *)1; } result = ltt_trace_set_type(trace_name, trace_type); if(result < 0) { ERR("ltt_trace_set_type failed"); - return; + return (void *)1; } } else if(!strcmp(recvbuf, "trace_alloc")) { @@ -296,7 +297,7 @@ int listener_main(void *p) result = ltt_trace_alloc(trace_name); if(result < 0) { ERR("ltt_trace_alloc failed"); - return; + return (void *)1; } } else if(!strcmp(recvbuf, "trace_start")) { @@ -314,7 +315,7 @@ int listener_main(void *p) result = ltt_trace_stop(trace_name); if(result < 0) { ERR("ltt_trace_stop failed"); - return; + return (void *)1; } } else if(!strcmp(recvbuf, "trace_destroy")) { @@ -324,7 +325,7 @@ int listener_main(void *p) result = ltt_trace_destroy(trace_name); if(result < 0) { ERR("ltt_trace_destroy failed"); - return; + return (void *)1; } } else if(nth_token_is(recvbuf, "get_shmid", 0) == 1) { @@ -347,7 +348,7 @@ int listener_main(void *p) if(trace == NULL) { CPRINTF("cannot find trace!"); - return 1; + return (void *)1; } for(i=0; inr_channels; i++) { @@ -395,7 +396,7 @@ int listener_main(void *p) if(trace == NULL) { CPRINTF("cannot find trace!"); - return 1; + return (void *)1; } for(i=0; inr_channels; i++) { @@ -404,8 +405,8 @@ int listener_main(void *p) if(!strcmp(trace->channels[i].channel_name, channel_name)) { char *reply; - DBG("the n_subbufs for the requested channel is %d", rchan->n_subbufs); - asprintf(&reply, "%d", rchan->n_subbufs); + DBG("the n_subbufs for the requested channel is %zd", rchan->n_subbufs); + asprintf(&reply, "%zd", rchan->n_subbufs); result = ustcomm_send_reply(&ustcomm_app.server, reply, &src); if(result) { @@ -439,7 +440,7 @@ int listener_main(void *p) if(trace == NULL) { CPRINTF("cannot find trace!"); - return 1; + return (void *)1; } for(i=0; inr_channels; i++) { @@ -448,8 +449,8 @@ int listener_main(void *p) if(!strcmp(trace->channels[i].channel_name, channel_name)) { char *reply; - DBG("the subbuf_size for the requested channel is %d", rchan->subbuf_size); - asprintf(&reply, "%d", rchan->subbuf_size); + DBG("the subbuf_size for the requested channel is %zd", rchan->subbuf_size); + asprintf(&reply, "%zd", rchan->subbuf_size); result = ustcomm_send_reply(&ustcomm_app.server, reply, &src); if(result) { @@ -490,7 +491,7 @@ int listener_main(void *p) if(trace == NULL) { CPRINTF("cannot find trace!"); - return 1; + return (void *)1; } for(i=0; inr_channels; i++) { @@ -556,7 +557,7 @@ int listener_main(void *p) if(trace == NULL) { CPRINTF("cannot find trace!"); - return 1; + return (void *)1; } for(i=0; inr_channels; i++) { @@ -571,11 +572,11 @@ int listener_main(void *p) result = ltt_do_put_subbuf(rbuf, lttbuf, consumed_old); if(result < 0) { WARN("ltt_do_put_subbuf: error (subbuf=%s)", channel_name); - asprintf(&reply, "%s", "ERROR", consumed_old); + asprintf(&reply, "%s", "ERROR"); } else { DBG("ltt_do_put_subbuf: success (subbuf=%s)", channel_name); - asprintf(&reply, "%s", "OK", consumed_old); + asprintf(&reply, "%s", "OK"); } result = ustcomm_send_reply(&ustcomm_app.server, reply, &src); @@ -649,7 +650,7 @@ int listener_main(void *p) // // if(trace == NULL) { // CPRINTF("cannot find trace!"); -// return 1; +// return (void *)1; // } // // for(i=0; inr_channels; i++) { diff --git a/libust/tracepoint.h b/libust/tracepoint.h index 81eea62..2bfb148 100644 --- a/libust/tracepoint.h +++ b/libust/tracepoint.h @@ -28,7 +28,9 @@ //#include //#include -//#include "urcu.h" +#define _LGPL_SOURCE +#include + #include "immediate.h" #include "kernelcompat.h" @@ -49,7 +51,8 @@ struct tracepoint { #define TPPROTO(args...) args #define TPARGS(args...) args -//ust// #ifdef CONFIG_TRACEPOINTS +#define CONFIG_TRACEPOINTS +#ifdef CONFIG_TRACEPOINTS /* * it_func[0] is never NULL because there is at least one element in the array @@ -126,29 +129,29 @@ struct tracepoint { extern void tracepoint_update_probe_range(struct tracepoint *begin, struct tracepoint *end); -//ust// #else /* !CONFIG_TRACEPOINTS */ -//ust// #define DECLARE_TRACE(name, proto, args) \ -//ust// static inline void trace_##name(proto) \ -//ust// { } \ -//ust// static inline void _trace_##name(proto) \ -//ust// { } \ -//ust// static inline int register_trace_##name(void (*probe)(proto)) \ -//ust// { \ -//ust// return -ENOSYS; \ -//ust// } \ -//ust// static inline int unregister_trace_##name(void (*probe)(proto)) \ -//ust// { \ -//ust// return -ENOSYS; \ -//ust// } -//ust// -//ust// #define DEFINE_TRACE(name) -//ust// #define EXPORT_TRACEPOINT_SYMBOL_GPL(name) -//ust// #define EXPORT_TRACEPOINT_SYMBOL(name) -//ust// -//ust// static inline void tracepoint_update_probe_range(struct tracepoint *begin, -//ust// struct tracepoint *end) -//ust// { } -//ust// #endif /* CONFIG_TRACEPOINTS */ +#else /* !CONFIG_TRACEPOINTS */ +#define DECLARE_TRACE(name, proto, args) \ + static inline void trace_##name(proto) \ + { } \ + static inline void _trace_##name(proto) \ + { } \ + static inline int register_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } \ + static inline int unregister_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } + +#define DEFINE_TRACE(name) +#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) +#define EXPORT_TRACEPOINT_SYMBOL(name) + +static inline void tracepoint_update_probe_range(struct tracepoint *begin, + struct tracepoint *end) +{ } +#endif /* CONFIG_TRACEPOINTS */ /* * Connect a probe to a tracepoint. @@ -195,12 +198,16 @@ struct tracepoint_lib { struct list_head list; }; -#define TRACEPOINT_LIB \ -extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden"))); \ -extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden"))); \ - \ -static void __attribute__((constructor)) __tracepoints__init(void) \ -{ \ - tracepoint_register_lib(__start___tracepoints, (((long)__stop___tracepoints)-((long)__start___tracepoints))/sizeof(struct tracepoint));\ -} +extern int tracepoint_register_lib(struct tracepoint *tracepoints_start, + int tracepoints_count); + +#define TRACEPOINT_LIB \ + extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden"))); \ + extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden"))); \ + static void __attribute__((constructor)) __tracepoints__init(void) \ + { \ + tracepoint_register_lib(__start___tracepoints, \ + (((long)__stop___tracepoints)-((long)__start___tracepoints))/sizeof(struct tracepoint)); \ + } + #endif diff --git a/ust/ust.c b/ust/ust.c index 79db498..b2f30f0 100644 --- a/ust/ust.c +++ b/ust/ust.c @@ -1,7 +1,8 @@ +#define _GNU_SOURCE +#include #include #include #include -#include #include #include "ustcomm.h" -- 2.34.1