From 7d61fa8e60df50c56bf2e27a4f27d205a608c7d2 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 26 Jan 2017 17:09:53 -0500 Subject: [PATCH] Plugins: use UNUSED_VAR instead of casting to void MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- plugins/ctf/fs/Makefile.am | 2 +- plugins/ctf/fs/fs.c | 4 ++-- plugins/ctf/lttng-live/Makefile.am | 2 +- plugins/ctf/lttng-live/lttng-live.c | 4 +++- plugins/muxer/Makefile.am | 2 +- plugins/muxer/muxer.c | 4 ++-- plugins/plugins-common.h | 32 +++++++++++++++++++++++++++++ plugins/text/Makefile.am | 2 +- plugins/text/text.c | 4 ++-- plugins/trimmer/Makefile.am | 2 +- plugins/trimmer/trimmer.c | 4 ++-- plugins/writer/Makefile.am | 2 +- plugins/writer/writer.c | 4 ++-- 13 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 plugins/plugins-common.h diff --git a/plugins/ctf/fs/Makefile.am b/plugins/ctf/fs/Makefile.am index c08c1aa9..4585c8ea 100644 --- a/plugins/ctf/fs/Makefile.am +++ b/plugins/ctf/fs/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/plugins noinst_HEADERS = \ fs.h \ diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index 75be8f13..450627d7 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -723,11 +724,10 @@ end: BT_HIDDEN enum bt_component_status ctf_fs_init(struct bt_component *source, - struct bt_value *params, void *init_method_data) + struct bt_value *params, UNUSED_VAR void *init_method_data) { struct ctf_fs_component *ctf_fs; enum bt_component_status ret = BT_COMPONENT_STATUS_OK; - (void) init_method_data; assert(source); ctf_fs_debug = g_strcmp0(getenv("CTF_FS_DEBUG"), "1") == 0; diff --git a/plugins/ctf/lttng-live/Makefile.am b/plugins/ctf/lttng-live/Makefile.am index 755be6e8..339e432c 100644 --- a/plugins/ctf/lttng-live/Makefile.am +++ b/plugins/ctf/lttng-live/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/plugins libbabeltrace_plugin_ctf_lttng_live_la_SOURCES = lttng-live.c diff --git a/plugins/ctf/lttng-live/lttng-live.c b/plugins/ctf/lttng-live/lttng-live.c index cac22503..add91ccb 100644 --- a/plugins/ctf/lttng-live/lttng-live.c +++ b/plugins/ctf/lttng-live/lttng-live.c @@ -28,16 +28,18 @@ #include "lttng-live-internal.h" #include +#include BT_HIDDEN enum bt_component_status lttng_live_iterator_init(struct bt_component *source, struct bt_notification_iterator *it) { + return BT_COMPONENT_STATUS_OK; } BT_HIDDEN enum bt_component_status lttng_live_init(struct bt_component *component, - struct bt_value *params, void *init_method_data) + struct bt_value *params, UNUSED_VAR void *init_method_data) { return BT_COMPONENT_STATUS_OK; } diff --git a/plugins/muxer/Makefile.am b/plugins/muxer/Makefile.am index a142a856..2aed0496 100644 --- a/plugins/muxer/Makefile.am +++ b/plugins/muxer/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/plugins SUBDIRS = . diff --git a/plugins/muxer/muxer.c b/plugins/muxer/muxer.c index cbc65c4a..f8eb7d30 100644 --- a/plugins/muxer/muxer.c +++ b/plugins/muxer/muxer.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "muxer.h" static @@ -63,11 +64,10 @@ void destroy_muxer(struct bt_component *component) enum bt_component_status muxer_component_init( struct bt_component *component, struct bt_value *params, - void *init_method_data) + UNUSED_VAR void *init_method_data) { enum bt_component_status ret; struct muxer *muxer = create_muxer(); - (void) init_method_data; if (!muxer) { ret = BT_COMPONENT_STATUS_NOMEM; diff --git a/plugins/plugins-common.h b/plugins/plugins-common.h new file mode 100644 index 00000000..c7377bf8 --- /dev/null +++ b/plugins/plugins-common.h @@ -0,0 +1,32 @@ +#ifndef PLUGINS_COMMON_H +#define PLUGINS_COMMON_H + +/* + * Copyright 2017 Philippe Proulx + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * UNUSED_VAR: tag a variable or parameter as explicitly unused so that + * the compiler does not warn. + */ +#define UNUSED_VAR __attribute__((unused)) + +#endif /* PLUGINS_COMMON_H */ diff --git a/plugins/text/Makefile.am b/plugins/text/Makefile.am index 8b12e312..cada4e3b 100644 --- a/plugins/text/Makefile.am +++ b/plugins/text/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/plugins SUBDIRS = . diff --git a/plugins/text/text.c b/plugins/text/text.c index 2652e6b2..78ddd4c5 100644 --- a/plugins/text/text.c +++ b/plugins/text/text.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -605,11 +606,10 @@ end: static enum bt_component_status text_component_init( struct bt_component *component, struct bt_value *params, - void *init_method_data) + UNUSED_VAR void *init_method_data) { enum bt_component_status ret; struct text_component *text = create_text(); - (void) init_method_data; if (!text) { ret = BT_COMPONENT_STATUS_NOMEM; diff --git a/plugins/trimmer/Makefile.am b/plugins/trimmer/Makefile.am index 4729bc4f..637564fa 100644 --- a/plugins/trimmer/Makefile.am +++ b/plugins/trimmer/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/plugins SUBDIRS = . diff --git a/plugins/trimmer/trimmer.c b/plugins/trimmer/trimmer.c index 2848c800..fd028d02 100644 --- a/plugins/trimmer/trimmer.c +++ b/plugins/trimmer/trimmer.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "trimmer.h" #include "iterator.h" #include @@ -350,11 +351,10 @@ end: enum bt_component_status trimmer_component_init( struct bt_component *component, struct bt_value *params, - void *init_method_data) + UNUSED_VAR void *init_method_data) { enum bt_component_status ret; struct trimmer *trimmer = create_trimmer_data(); - (void) init_method_data; if (!trimmer) { ret = BT_COMPONENT_STATUS_NOMEM; diff --git a/plugins/writer/Makefile.am b/plugins/writer/Makefile.am index 33116567..2f3239eb 100644 --- a/plugins/writer/Makefile.am +++ b/plugins/writer/Makefile.am @@ -1,4 +1,4 @@ -AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include +AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/plugins SUBDIRS = . diff --git a/plugins/writer/writer.c b/plugins/writer/writer.c index 4b36757f..8e470376 100644 --- a/plugins/writer/writer.c +++ b/plugins/writer/writer.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -214,14 +215,13 @@ end: static enum bt_component_status writer_component_init( struct bt_component *component, struct bt_value *params, - void *init_method_data) + UNUSED_VAR void *init_method_data) { enum bt_component_status ret; enum bt_value_status value_ret; struct writer_component *writer_component = create_writer_component(); struct bt_value *value = NULL; const char *path; - (void) init_method_data; if (!writer_component) { ret = BT_COMPONENT_STATUS_NOMEM; -- 2.34.1