linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin()
@ 2017-04-24 13:43 Taeung Song
  2017-04-25 23:11 ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Taeung Song @ 2017-04-24 13:43 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, Taeung Song

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin()
  2017-04-24 13:43 [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin() Taeung Song
@ 2017-04-25 23:11 ` Steven Rostedt
  2017-04-26 14:56   ` Taeung Song
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2017-04-25 23:11 UTC (permalink / raw)
  To: Taeung Song; +Cc: linux-kernel, Federico Vaga

On Mon, 24 Apr 2017 22:43:31 +0900
Taeung Song <treeze.taeung@gmail.com> 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 <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;

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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin()
  2017-04-25 23:11 ` Steven Rostedt
@ 2017-04-26 14:56   ` Taeung Song
  2017-04-26 17:54     ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Taeung Song @ 2017-04-26 14:56 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, Federico Vaga

Hi Steven :)

On 04/26/2017 08:11 AM, Steven Rostedt wrote:
> On Mon, 24 Apr 2017 22:43:31 +0900
> Taeung Song <treeze.taeung@gmail.com> 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 <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;
>
> 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?
>

Yes! I want to do it.
After you update 'master' branch on your repo 
(git.kernel.org/.../trace-cmd.git), I'll send a patch as you said !

And would you mind if I ask you to check another patch I sent ?

   "[PATCH] Fix pevent_filter_clear_trivial()"

But I'll renewedly send the patch after I a bit modified it.
I'd appreciate it if you check the patch, too. :)

Thanks,
Taeung

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin()
  2017-04-26 14:56   ` Taeung Song
@ 2017-04-26 17:54     ` Steven Rostedt
  2017-04-26 22:51       ` Taeung Song
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2017-04-26 17:54 UTC (permalink / raw)
  To: Taeung Song; +Cc: linux-kernel, Federico Vaga

On Wed, 26 Apr 2017 23:56:02 +0900
Taeung Song <treeze.taeung@gmail.com> wrote:

> > Want to send another patch on top of Federico's?
> >  
> 
> Yes! I want to do it.
> After you update 'master' branch on your repo 

I just updated my master branch.

> (git.kernel.org/.../trace-cmd.git), I'll send a patch as you said !
> 
> And would you mind if I ask you to check another patch I sent ?
> 
>    "[PATCH] Fix pevent_filter_clear_trivial()"
> 
> But I'll renewedly send the patch after I a bit modified it.
> I'd appreciate it if you check the patch, too. :)

I still have the original patch. You want me to apply the new one. It
does have a better change log, but I'll probably update the log on it
too.

-- Steve

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin()
  2017-04-26 17:54     ` Steven Rostedt
@ 2017-04-26 22:51       ` Taeung Song
  0 siblings, 0 replies; 5+ messages in thread
From: Taeung Song @ 2017-04-26 22:51 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, Federico Vaga



On 04/27/2017 02:54 AM, Steven Rostedt wrote:
> On Wed, 26 Apr 2017 23:56:02 +0900
> Taeung Song <treeze.taeung@gmail.com> wrote:
>
>>> Want to send another patch on top of Federico's?
>>>
>>
>> Yes! I want to do it.
>> After you update 'master' branch on your repo
>
> I just updated my master branch.
>

I got it !
I'll send the new patch you said. :)

>> (git.kernel.org/.../trace-cmd.git), I'll send a patch as you said !
>>
>> And would you mind if I ask you to check another patch I sent ?
>>
>>    "[PATCH] Fix pevent_filter_clear_trivial()"
>>
>> But I'll renewedly send the patch after I a bit modified it.
>> I'd appreciate it if you check the patch, too. :)
>
> I still have the original patch. You want me to apply the new one. It
> does have a better change log, but I'll probably update the log on it
> too.
>
> -- Steve
>

Thank you !!

Taeung

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-26 22:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-24 13:43 [PATCH] trace-cmd: Fix a warning about incompatible pointer type of load_plugin() Taeung Song
2017-04-25 23:11 ` Steven Rostedt
2017-04-26 14:56   ` Taeung Song
2017-04-26 17:54     ` Steven Rostedt
2017-04-26 22:51       ` Taeung Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).