From fbae86d664c12e450d3cb702b602701d37781b41 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 10 Feb 2011 13:36:54 -0500 Subject: [PATCH] UST-wide warning fixes/bugfixes Signed-off-by: Mathieu Desnoyers --- configure.ac | 2 ++ include/ust/ust_trace.h | 2 +- libust-initializer.c | 5 ++--- libust/buffers.c | 1 + libust/buffers.h | 1 + libust/marker.c | 1 + libust/tracectl.c | 4 ++-- libustcomm/ustcomm.c | 2 +- libustconsumer/libustconsumer.c | 5 +++-- libustconsumer/lowlevel.c | 5 +++-- .../libustctl_function_tests/libustctl_function_tests.c | 7 +++---- tests/register_test/register_test.c | 3 ++- tests/tap.c | 1 + tests/trace_event/trace_event_test.c | 1 + ust-consumerd/ust-consumerd.c | 9 +++++---- 15 files changed, 29 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 2b2962a5..e57b3562 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,8 @@ AC_C_INLINE AC_FUNC_MALLOC AC_CHECK_FUNCS([gettimeofday munmap socket strerror strtol]) +CFLAGS="-Wall $CFLAGS" + # URCU # urcu - check if we just find the headers it out of the box. diff --git a/include/ust/ust_trace.h b/include/ust/ust_trace.h index cedd47fd..11d5940c 100644 --- a/include/ust/ust_trace.h +++ b/include/ust/ust_trace.h @@ -84,7 +84,7 @@ }; \ static void __attribute__((constructor)) init_##name() \ { \ - void *dummy; \ + void *dummy = NULL; \ register_trace_##name(trace_printf_##name, dummy); \ } diff --git a/libust-initializer.c b/libust-initializer.c index 2ac56375..a7103389 100644 --- a/libust-initializer.c +++ b/libust-initializer.c @@ -26,10 +26,9 @@ DEFINE_TRACE(ust_dummytp); void dummy_libust_initializer_func(void) { - int i; trace_mark(ust, dummymark, MARK_NOARGS); - trace_ust_dummytp(i); - trace_ust_dummy_event(i); + trace_ust_dummytp(0); + trace_ust_dummy_event(0); } MARKER_LIB; diff --git a/libust/buffers.c b/libust/buffers.c index e5a1db39..2e6a1618 100644 --- a/libust/buffers.c +++ b/libust/buffers.c @@ -655,6 +655,7 @@ static int unmap_buf_structs(struct ust_channel *chan) PERROR("shmdt"); } } + return 0; } /* diff --git a/libust/buffers.h b/libust/buffers.h index eb75c8b6..ddacdffe 100644 --- a/libust/buffers.h +++ b/libust/buffers.h @@ -26,6 +26,7 @@ #include #include +#include #include "usterr.h" #include "channels.h" diff --git a/libust/marker.c b/libust/marker.c index 2618b1ae..7a32351b 100644 --- a/libust/marker.c +++ b/libust/marker.c @@ -25,6 +25,7 @@ #include #include +#include #include "usterr.h" #include "channels.h" diff --git a/libust/tracectl.c b/libust/tracectl.c index e877e628..25fa4d57 100644 --- a/libust/tracectl.c +++ b/libust/tracectl.c @@ -355,7 +355,7 @@ static int set_subbuf_size(const char *trace_name, const char *ch_name, } channel->subbuf_size = power; - DBG("the set_subbuf_size for the requested channel is %u", channel->subbuf_size); + DBG("the set_subbuf_size for the requested channel is %zu", channel->subbuf_size); unlock_traces: ltt_unlock_traces(); @@ -393,7 +393,7 @@ static int set_subbuf_num(const char *trace_name, const char *ch_name, } channel->subbuf_cnt = num; - DBG("the set_subbuf_cnt for the requested channel is %zd", channel->subbuf_cnt); + DBG("the set_subbuf_cnt for the requested channel is %u", channel->subbuf_cnt); unlock_traces: ltt_unlock_traces(); diff --git a/libustcomm/ustcomm.c b/libustcomm/ustcomm.c index 9b1d83a9..43f4289a 100644 --- a/libustcomm/ustcomm.c +++ b/libustcomm/ustcomm.c @@ -371,7 +371,7 @@ int ustcomm_recv_fd(int sock, if (peek_header.size && data) { if (peek_header.size < 0 || peek_header.size > USTCOMM_DATA_SIZE) { - ERR("big peek header! %d", peek_header.size); + ERR("big peek header! %ld", peek_header.size); return 0; } diff --git a/libustconsumer/libustconsumer.c b/libustconsumer/libustconsumer.c index 6cb3dbf3..739a2223 100644 --- a/libustconsumer/libustconsumer.c +++ b/libustconsumer/libustconsumer.c @@ -487,6 +487,7 @@ int consumer_loop(struct ustconsumer_instance *instance, struct buffer_info *buf /* Skip the first subbuffer. We are not sure it is trustable * because the put_subbuffer() did not complete. */ + /* TODO: check on_put_error return value */ if(instance->callbacks->on_put_error) instance->callbacks->on_put_error(instance->callbacks, buf); @@ -598,7 +599,7 @@ int start_consuming_buffer(struct ustconsumer_instance *instance, pid_t pid, args->channel_cpu = channel_cpu; args->instance = instance; DBG("beginning2 of start_consuming_buffer: args: pid %d trace %s" - " bufname %s_%d", args->pid, args->channel, args->channel_cpu); + " bufname %s_%d", args->pid, args->trace, args->channel, args->channel_cpu); result = pthread_create(&thr, NULL, consumer_thread, args); if(result == -1) { @@ -611,7 +612,7 @@ int start_consuming_buffer(struct ustconsumer_instance *instance, pid_t pid, return -1; } DBG("end of start_consuming_buffer: args: pid %d trace %s " - "bufname %s_%d", args->pid, args->channel, args->channel_cpu); + "bufname %s_%d", args->pid, args->channel, args->trace, args->channel_cpu); return 0; } diff --git a/libustconsumer/lowlevel.c b/libustconsumer/lowlevel.c index 7eb124b9..730dd110 100644 --- a/libustconsumer/lowlevel.c +++ b/libustconsumer/lowlevel.c @@ -118,7 +118,7 @@ void finish_consuming_dead_subbuffer(struct ustconsumer_callbacks *callbacks, st /* If it was, we only check the data_size. This is the amount of valid data at * the beginning of the subbuffer. */ valid_length = header->data_size; - DBG("writing full subbuffer (%d) with valid_length = %ld", i_subbuf, valid_length); + DBG("writing full subbuffer (%ld) with valid_length = %ld", i_subbuf, valid_length); } else { /* If the subbuffer was not fully written, then we don't check data_size because @@ -127,12 +127,13 @@ void finish_consuming_dead_subbuffer(struct ustconsumer_callbacks *callbacks, st */ valid_length = commit_seq & (buf->subbuf_size-1); - DBG("writing unfull subbuffer (%d) with valid_length = %ld", i_subbuf, valid_length); + DBG("writing unfull subbuffer (%ld) with valid_length = %ld", i_subbuf, valid_length); header->data_size = valid_length; header->sb_size = PAGE_ALIGN(valid_length); assert(i_subbuf == (last_subbuf % buf->n_subbufs)); } + /* TODO: check on_read_partial_subbuffer return value */ if(callbacks->on_read_partial_subbuffer) callbacks->on_read_partial_subbuffer(callbacks, buf, i_subbuf, valid_length); diff --git a/tests/libustctl_function_tests/libustctl_function_tests.c b/tests/libustctl_function_tests/libustctl_function_tests.c index 784ff5d0..947028f9 100644 --- a/tests/libustctl_function_tests/libustctl_function_tests.c +++ b/tests/libustctl_function_tests/libustctl_function_tests.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -155,12 +156,10 @@ static void ustctl_function_tests(pid_t pid) } - -int main() +int main(int argc, char **argv) { - int i, status, pipefd[2]; + int i, status; pid_t parent_pid, child_pid; - FILE *pipe_file; tap_plan(27); diff --git a/tests/register_test/register_test.c b/tests/register_test/register_test.c index 90fca12e..b593185e 100644 --- a/tests/register_test/register_test.c +++ b/tests/register_test/register_test.c @@ -79,10 +79,11 @@ static void * register_thread_main(void *data) } printf("Unregistered all\n"); } + return NULL; } -int main() +int main(int argc, char **argv) { pthread_t register_thread; int i; diff --git a/tests/tap.c b/tests/tap.c index 940cc1ae..bd7f81cc 100644 --- a/tests/tap.c +++ b/tests/tap.c @@ -18,6 +18,7 @@ #include #include #include +#include static int tap_planned = -1; static int tap_count = 1; diff --git a/tests/trace_event/trace_event_test.c b/tests/trace_event/trace_event_test.c index 9ed3d6ce..f4fa90a8 100644 --- a/tests/trace_event/trace_event_test.c +++ b/tests/trace_event/trace_event_test.c @@ -27,4 +27,5 @@ int main(int argc, char * argv[]) time=trace_clock_read64(); trace_test(time, i); } + return 0; } diff --git a/ust-consumerd/ust-consumerd.c b/ust-consumerd/ust-consumerd.c index fae4efaf..ce2ee40a 100644 --- a/ust-consumerd/ust-consumerd.c +++ b/ust-consumerd/ust-consumerd.c @@ -33,6 +33,7 @@ #include #include "ust/ustconsumer.h" +#include "../libustconsumer/lowlevel.h" #include "usterr.h" char *sock_path=NULL; @@ -144,7 +145,7 @@ int on_read_partial_subbuffer(struct ustconsumer_callbacks *data, struct buffer_ result = patient_write(buf_local->file_fd, buf->mem + subbuf_index * buf->subbuf_size, valid_length); if(result == -1) { ERR("Error writing to buffer file"); - return; + return result; } /* pad with empty bytes */ @@ -154,11 +155,11 @@ int on_read_partial_subbuffer(struct ustconsumer_callbacks *data, struct buffer_ result = patient_write(buf_local->file_fd, tmp, pad_size); if(result == -1) { ERR("Error writing to buffer file"); - return; + return result; } free(tmp); } - + return result; } int on_open_buffer(struct ustconsumer_callbacks *data, struct buffer_info *buf) @@ -234,7 +235,7 @@ int on_close_buffer(struct ustconsumer_callbacks *data, struct buffer_info *buf) int on_put_error(struct ustconsumer_callbacks *data, struct buffer_info *buf) { - unwrite_last_subbuffer(buf); + return unwrite_last_subbuffer(buf); } struct ustconsumer_callbacks *new_callbacks() -- 2.34.1