Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1629589

[PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin()

From Taeung Song <treeze.taeung@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin()
Date 2017-04-24 15:50 +0200
Message-ID <tzMxj-7FA-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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,
     ^

Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
 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;
 	} else
 		Py_DECREF(res);
 
 	free(load);
+	return 0;
 }
 
 int PEVENT_PLUGIN_LOADER(struct pevent *pevent)
-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin() Taeung Song <treeze.taeung@gmail.com> - 2017-04-24 15:50 +0200
  Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer  type of load_plugin() Steven Rostedt <rostedt@goodmis.org> - 2017-04-26 01:20 +0200
    Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer type  of load_plugin() Taeung Song <treeze.taeung@gmail.com> - 2017-04-26 17:00 +0200
      Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer  type of load_plugin() Steven Rostedt <rostedt@goodmis.org> - 2017-04-26 20:00 +0200
        Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer type  of load_plugin() Taeung Song <treeze.taeung@gmail.com> - 2017-04-27 01:00 +0200

csiph-web