linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] parse-events: deref pointer for proper sizeof()
@ 2019-08-05 10:26 Sergey Senozhatsky
  2019-08-05 10:26 ` [PATCH 2/2] " Sergey Senozhatsky
  2019-08-06  3:21 ` [PATCH 1/2] " Steven Rostedt
  0 siblings, 2 replies; 7+ messages in thread
From: Sergey Senozhatsky @ 2019-08-05 10:26 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel, Sergey Senozhatsky

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 parse-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parse-events.c b/parse-events.c
index 3d59d92..807fc53 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -2058,7 +2058,7 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
 			goto out_free;
 
 		field = malloc_or_die(sizeof(*field));
-		memset(field, 0, sizeof(field));
+		memset(field, 0, sizeof(*field));
 
 		value = arg_eval(arg);
 		field->value = strdup(value);
-- 
2.22.0


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

* [PATCH 2/2] parse-events: deref pointer for proper sizeof()
  2019-08-05 10:26 [PATCH 1/2] parse-events: deref pointer for proper sizeof() Sergey Senozhatsky
@ 2019-08-05 10:26 ` Sergey Senozhatsky
  2019-08-06  3:21 ` [PATCH 1/2] " Steven Rostedt
  1 sibling, 0 replies; 7+ messages in thread
From: Sergey Senozhatsky @ 2019-08-05 10:26 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel, Sergey Senozhatsky

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 parse-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/parse-events.c b/parse-events.c
index 807fc53..1a25a7d 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -4778,7 +4778,7 @@ int pevent_register_event_handler(struct pevent *pevent,
  not_found:
 	/* Save for later use. */
 	handle = malloc_or_die(sizeof(*handle));
-	memset(handle, 0, sizeof(handle));
+	memset(handle, 0, sizeof(*handle));
 	handle->id = id;
 	if (event_name)
 		handle->event_name = strdup(event_name);
-- 
2.22.0


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

* Re: [PATCH 1/2] parse-events: deref pointer for proper sizeof()
  2019-08-05 10:26 [PATCH 1/2] parse-events: deref pointer for proper sizeof() Sergey Senozhatsky
  2019-08-05 10:26 ` [PATCH 2/2] " Sergey Senozhatsky
@ 2019-08-06  3:21 ` Steven Rostedt
  2019-08-06  5:14   ` Sergey Senozhatsky
  1 sibling, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2019-08-06  3:21 UTC (permalink / raw)
  To: Sergey Senozhatsky; +Cc: linux-trace-devel, Sergey Senozhatsky

On Mon,  5 Aug 2019 19:26:45 +0900
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:

> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> ---

Hi Sergey,

Thanks for sending these!

-- Steve

>  parse-events.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/parse-events.c b/parse-events.c
> index 3d59d92..807fc53 100644
> --- a/parse-events.c
> +++ b/parse-events.c
> @@ -2058,7 +2058,7 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
>  			goto out_free;
>  
>  		field = malloc_or_die(sizeof(*field));
> -		memset(field, 0, sizeof(field));
> +		memset(field, 0, sizeof(*field));
>  
>  		value = arg_eval(arg);
>  		field->value = strdup(value);


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

* Re: [PATCH 1/2] parse-events: deref pointer for proper sizeof()
  2019-08-06  3:21 ` [PATCH 1/2] " Steven Rostedt
@ 2019-08-06  5:14   ` Sergey Senozhatsky
  2019-08-06  5:41     ` Sergey Senozhatsky
  0 siblings, 1 reply; 7+ messages in thread
From: Sergey Senozhatsky @ 2019-08-06  5:14 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Sergey Senozhatsky, linux-trace-devel, Sergey Senozhatsky

On (08/05/19 23:21), Steven Rostedt wrote:
> On Mon,  5 Aug 2019 19:26:45 +0900
> Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:
> 
> > Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > ---
> 
> Hi Sergey,
> 
> Thanks for sending these!

Hi Steven,

I just realised that the patches are against v1.1.1, not the master
branch. Let me know if it's not OK.


I've some issues building v1.1.1.

	swig -Wall -python -noproxy ctracecmd.i
	parse-events.h:676: Error: Syntax error in input(3).

Which is, probably, this 'bool' variable of type filter_arg_boolean

struct filter_arg {
        enum filter_arg_type    type;
        union {
                struct filter_arg_boolean       bool;        <<<< 676
                struct filter_arg_field         field;
                struct filter_arg_value         value;
                struct filter_arg_op            op;
                struct filter_arg_exp           exp;
                struct filter_arg_num           num;
                struct filter_arg_str           str;
        };
};

Is this a known problem?

	-ss

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

* Re: [PATCH 1/2] parse-events: deref pointer for proper sizeof()
  2019-08-06  5:14   ` Sergey Senozhatsky
@ 2019-08-06  5:41     ` Sergey Senozhatsky
  2019-08-06  6:07       ` Sergey Senozhatsky
  0 siblings, 1 reply; 7+ messages in thread
From: Sergey Senozhatsky @ 2019-08-06  5:41 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel, Sergey Senozhatsky, Sergey Senozhatsky

On (08/06/19 14:14), Sergey Senozhatsky wrote:
> Hi Steven,
> 
> I just realised that the patches are against v1.1.1, not the master
> branch. Let me know if it's not OK.
> 
> 
> I've some issues building v1.1.1.
> 
> 	swig -Wall -python -noproxy ctracecmd.i
> 	parse-events.h:676: Error: Syntax error in input(3).
> 
> Which is, probably, this 'bool' variable of type filter_arg_boolean
> 
> struct filter_arg {
>         enum filter_arg_type    type;
>         union {
>                 struct filter_arg_boolean       bool;        <<<< 676
>                 struct filter_arg_field         field;
>                 struct filter_arg_value         value;
>                 struct filter_arg_op            op;
>                 struct filter_arg_exp           exp;
>                 struct filter_arg_num           num;
>                 struct filter_arg_str           str;
>         };
> };
> 
> Is this a known problem?

This patch seems to do the trick for me.

---

diff --git a/parse-events.h b/parse-events.h
index 3a4ef08..01be4f0 100644
--- a/parse-events.h
+++ b/parse-events.h
@@ -673,7 +673,7 @@ struct filter_arg_str {
 struct filter_arg {
 	enum filter_arg_type	type;
 	union {
-		struct filter_arg_boolean	bool;
+		struct filter_arg_boolean	boolean;
 		struct filter_arg_field		field;
 		struct filter_arg_value		value;
 		struct filter_arg_op		op;
diff --git a/parse-filter.c b/parse-filter.c
index 0d448cb..13f3422 100644
--- a/parse-filter.c
+++ b/parse-filter.c
@@ -359,7 +359,7 @@ create_arg_item(struct event_format *event,
 			if (strcmp(token, COMM) != 0) {
 				/* not a field, Make it false */
 				arg->type = FILTER_ARG_BOOLEAN;
-				arg->bool.value = FILTER_FALSE;
+				arg->boolean.value = FILTER_FALSE;
 				break;
 			}
 			/* If token is 'COMM' then it is special */
@@ -487,7 +487,7 @@ static int add_right(struct filter_arg *op, struct filter_arg *arg,
 				free_arg(left);
 				free_arg(arg);
 				op->type = FILTER_ARG_BOOLEAN;
-				op->bool.value = FILTER_FALSE;
+				op->boolean.value = FILTER_FALSE;
 				break;
 			}
 
@@ -772,7 +772,7 @@ enum filter_vals test_arg(struct filter_arg *parent, struct filter_arg *arg)
 
 		/* bad case */
 	case FILTER_ARG_BOOLEAN:
-		return FILTER_VAL_FALSE + arg->bool.value;
+		return FILTER_VAL_FALSE + arg->boolean.value;
 
 		/* good cases: */
 	case FILTER_ARG_STR:
@@ -871,7 +871,7 @@ static struct filter_arg *collapse_tree(struct filter_arg *arg)
 		free_arg(arg);
 		arg = allocate_arg();
 		arg->type = FILTER_ARG_BOOLEAN;
-		arg->bool.value = ret == FILTER_VAL_TRUE;
+		arg->boolean.value = ret == FILTER_VAL_TRUE;
 	}
 
 	return arg;
@@ -1116,7 +1116,7 @@ process_event(struct event_format *event, const char *filter_str,
 	if (!*parg) {
 		*parg = allocate_arg();
 		(*parg)->type = FILTER_ARG_BOOLEAN;
-		(*parg)->bool.value = FILTER_FALSE;
+		(*parg)->boolean.value = FILTER_FALSE;
 	}
 
 	return 0;
@@ -1139,7 +1139,7 @@ static int filter_event(struct event_filter *filter,
 		/* just add a TRUE arg */
 		arg = allocate_arg();
 		arg->type = FILTER_ARG_BOOLEAN;
-		arg->bool.value = FILTER_TRUE;
+		arg->boolean.value = FILTER_TRUE;
 	}
 
 	filter_type = add_filter_type(filter, event->id);
@@ -1369,9 +1369,9 @@ static int copy_filter_type(struct event_filter *filter,
 		arg = allocate_arg();
 		arg->type = FILTER_ARG_BOOLEAN;
 		if (strcmp(str, "TRUE") == 0)
-			arg->bool.value = 1;
+			arg->boolean.value = 1;
 		else
-			arg->bool.value = 0;
+			arg->boolean.value = 0;
 
 		filter_type = add_filter_type(filter, event->id);
 		filter_type->filter = arg;
@@ -1442,8 +1442,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
 		arg = filter_type->filter;
 		if (arg->type != FILTER_ARG_BOOLEAN)
 			continue;
-		if ((arg->bool.value && type == FILTER_TRIVIAL_FALSE) ||
-		    (!arg->bool.value && type == FILTER_TRIVIAL_TRUE))
+		if ((arg->boolean.value && type == FILTER_TRIVIAL_FALSE) ||
+		    (!arg->boolean.value && type == FILTER_TRIVIAL_TRUE))
 			continue;
 
 		event = filter_type->event;
@@ -1497,10 +1497,10 @@ void pevent_filter_clear_trivial(struct event_filter *filter,
 			continue;
 		switch (type) {
 		case FILTER_TRIVIAL_FALSE:
-			if (filter_type->filter->bool.value)
+			if (filter_type->filter->boolean.value)
 				continue;
 		case FILTER_TRIVIAL_TRUE:
-			if (!filter_type->filter->bool.value)
+			if (!filter_type->filter->boolean.value)
 				continue;
 		default:
 			break;
@@ -1551,10 +1551,10 @@ int pevent_filter_event_has_trivial(struct event_filter *filter,
 
 	switch (type) {
 	case FILTER_TRIVIAL_FALSE:
-		return !filter_type->filter->bool.value;
+		return !filter_type->filter->boolean.value;
 
 	case FILTER_TRIVIAL_TRUE:
-		return filter_type->filter->bool.value;
+		return filter_type->filter->boolean.value;
 	default:
 		return 1;
 	}
@@ -1783,7 +1783,7 @@ static int test_filter(struct event_format *event,
 	switch (arg->type) {
 	case FILTER_ARG_BOOLEAN:
 		/* easy case */
-		return arg->bool.value;
+		return arg->boolean.value;
 
 	case FILTER_ARG_OP:
 		return test_op(event, arg, record);
@@ -2147,7 +2147,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
 	switch (arg->type) {
 	case FILTER_ARG_BOOLEAN:
 		str = malloc_or_die(6);
-		if (arg->bool.value)
+		if (arg->boolean.value)
 			strcpy(str, "TRUE");
 		else
 			strcpy(str, "FALSE");

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

* Re: [PATCH 1/2] parse-events: deref pointer for proper sizeof()
  2019-08-06  5:41     ` Sergey Senozhatsky
@ 2019-08-06  6:07       ` Sergey Senozhatsky
  2019-08-06 12:50         ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Sergey Senozhatsky @ 2019-08-06  6:07 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-trace-devel, Sergey Senozhatsky, Sergey Senozhatsky

On (08/06/19 14:41), Sergey Senozhatsky wrote:
> 
> This patch seems to do the trick for me.
> 

D'oh...

Steven, please scratch all these patches which I have sent.
Something terribly wrong happened on my box and git didn't pull
the current master properly yesterday. Somehow. No sure I understand
how, tho. I looked at very outdated source code tree.

Sorry for the noise!!

	-ss

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

* Re: [PATCH 1/2] parse-events: deref pointer for proper sizeof()
  2019-08-06  6:07       ` Sergey Senozhatsky
@ 2019-08-06 12:50         ` Steven Rostedt
  0 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2019-08-06 12:50 UTC (permalink / raw)
  To: Sergey Senozhatsky; +Cc: linux-trace-devel, Sergey Senozhatsky

On Tue, 6 Aug 2019 15:07:30 +0900
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:

> On (08/06/19 14:41), Sergey Senozhatsky wrote:
> > 
> > This patch seems to do the trick for me.
> >   
> 
> D'oh...
> 
> Steven, please scratch all these patches which I have sent.
> Something terribly wrong happened on my box and git didn't pull
> the current master properly yesterday. Somehow. No sure I understand
> how, tho. I looked at very outdated source code tree.
> 
> Sorry for the noise!!

heh, no problem.

-- Steve


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

end of thread, other threads:[~2019-08-06 12:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05 10:26 [PATCH 1/2] parse-events: deref pointer for proper sizeof() Sergey Senozhatsky
2019-08-05 10:26 ` [PATCH 2/2] " Sergey Senozhatsky
2019-08-06  3:21 ` [PATCH 1/2] " Steven Rostedt
2019-08-06  5:14   ` Sergey Senozhatsky
2019-08-06  5:41     ` Sergey Senozhatsky
2019-08-06  6:07       ` Sergey Senozhatsky
2019-08-06 12:50         ` Steven Rostedt

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).