Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1433495AbdDYXLN convert rfc822-to-8bit (ORCPT ); Tue, 25 Apr 2017 19:11:13 -0400 Received: from mail.kernel.org ([198.145.29.136]:55082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1433478AbdDYXLF (ORCPT ); Tue, 25 Apr 2017 19:11:05 -0400 Date: Tue, 25 Apr 2017 19:11:00 -0400 From: Steven Rostedt To: Taeung Song Cc: linux-kernel@vger.kernel.org, Federico Vaga Subject: Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin() Message-ID: <20170425191100.588b5395@gandalf.local.home> In-Reply-To: <1493041411-28428-1-git-send-email-treeze.taeung@gmail.com> References: <1493041411-28428-1-git-send-email-treeze.taeung@gmail.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2766 Lines: 81 On Mon, 24 Apr 2017 22:43:31 +0900 Taeung Song wrote: > Currently the return type of load_plugin() in plugin_python.c is void type, > but it is different from the argument type of trace_util_load_plugins(). > So fix it for the below warning. > > /home/taeung/git/opensource/trace-cmd/plugin_python.c: In function ‘pevent_plugin_loader’: > /home/taeung/git/opensource/trace-cmd/plugin_python.c:95:41: warning: passing argument 3 of ‘trace_util_load_plugins’ from incompatible pointer type [-Wincompatible-pointer-types] > trace_util_load_plugins(pevent, ".py", load_plugin, globals); > ^ > In file included from /home/taeung/git/opensource/trace-cmd/plugin_python.c:3:0: > /home/taeung/git/opensource/trace-cmd/trace-cmd.h:300:5: note: expected ‘int (*)(struct pevent *, const char *, const char *, void *)’ but argument is of type ‘void (*)(struct pevent *, const char *, const char *, void *)’ > int trace_util_load_plugins(struct pevent *pevent, const char *suffix, > ^ > Thanks but Federico beat you to it. http://lkml.kernel.org/r/20170423102258.21609-2-federico.vaga@vaga.pv.it I'll be updating and pushing out a new trace-cmd this week. > Signed-off-by: Taeung Song > --- > plugin_python.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/plugin_python.c b/plugin_python.c > index da07d27..d736f50 100644 > --- a/plugin_python.c > +++ b/plugin_python.c > @@ -20,7 +20,7 @@ static const char pyload[] = > "finally:\n" > " file.close()\n"; > > -static void load_plugin(struct pevent *pevent, const char *path, > +static int load_plugin(struct pevent *pevent, const char *path, > const char *name, void *data) > { > PyObject *globals = data; > @@ -32,7 +32,7 @@ static void load_plugin(struct pevent *pevent, const char *path, > PyObject *res; > > if (!full || !n) > - return; > + return -ENOMEM; > > strcpy(full, path); > strcat(full, "/"); > @@ -43,16 +43,18 @@ static void load_plugin(struct pevent *pevent, const char *path, > > asprintf(&load, pyload, full, n); > if (!load) > - return; > + return -1; > > res = PyRun_String(load, Py_file_input, globals, globals); > if (!res) { > fprintf(stderr, "failed loading %s\n", full); > PyErr_Print(); > + return -1; Although, Federico's version didn't have this. I may add this under your patch. Although, it requires freeing load. The better way would be to set a "ret" variable and return that. Want to send another patch on top of Federico's? Thanks! -- Steve > } else > Py_DECREF(res); > > free(load); > + return 0; > } > > int PEVENT_PLUGIN_LOADER(struct pevent *pevent)