linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Initialize field_size prior to use
@ 2022-09-28 21:09 Ian Rogers
  2022-09-28 21:26 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2022-09-28 21:09 UTC (permalink / raw)
  To: linux-trace-devel, Tzvetomir Stoyanov, Steven Rostedt; +Cc: Ian Rogers

Building with CC=clang yields:

```
  COMPILE FPIC       event-parse.o
event-parse.c:4313:17: warning: variable 'field_size' is uninitialized when used here [-Wuninitialized]
                                           offset, field_size)) {
                                                   ^~~~~~~~~~
event-parse.c:4108:25: note: initialize the variable 'field_size' to silence this warning
        unsigned int field_size;
                               ^
                                = 0
1 warning generated.
```

dynamic_offset_field will compute the length of the field and so use
that to give field_size a legitimate value.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 src/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/event-parse.c b/src/event-parse.c
index 980e980..b3e0ea7 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -4308,7 +4308,7 @@ eval_num_arg(void *data, int size, struct tep_event *event, struct tep_print_arg
 	case TEP_PRINT_DYNAMIC_ARRAY:
 		/* Without [], we pass the address to the dynamic data */
 		dynamic_offset_field(tep, arg->dynarray.field, data, size,
-				     &offset, NULL);
+				     &offset, &field_size);
 		if (check_data_offset_size(event, arg->field.name, size,
 					   offset, field_size)) {
 			val = (unsigned long)data;
-- 
2.38.0.rc1.362.ged0d419d3c-goog


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

* Re: [PATCH] Initialize field_size prior to use
  2022-09-28 21:09 [PATCH] Initialize field_size prior to use Ian Rogers
@ 2022-09-28 21:26 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2022-09-28 21:26 UTC (permalink / raw)
  To: Ian Rogers; +Cc: linux-trace-devel, Tzvetomir Stoyanov

On Wed, 28 Sep 2022 14:09:31 -0700
Ian Rogers <irogers@google.com> wrote:

> Building with CC=clang yields:
> 
> ```
>   COMPILE FPIC       event-parse.o
> event-parse.c:4313:17: warning: variable 'field_size' is uninitialized when used here [-Wuninitialized]
>                                            offset, field_size)) {
>                                                    ^~~~~~~~~~
> event-parse.c:4108:25: note: initialize the variable 'field_size' to silence this warning
>         unsigned int field_size;
>                                ^
>                                 = 0
> 1 warning generated.
> ```
> 
> dynamic_offset_field will compute the length of the field and so use
> that to give field_size a legitimate value.

Actually the field_size is not needed here.

I have a patch pending to fix this:

  https://patchwork.kernel.org/project/linux-trace-devel/patch/20220923123014.489e0e39@gandalf.local.home/

-- Steve

> 
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  src/event-parse.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/event-parse.c b/src/event-parse.c
> index 980e980..b3e0ea7 100644
> --- a/src/event-parse.c
> +++ b/src/event-parse.c
> @@ -4308,7 +4308,7 @@ eval_num_arg(void *data, int size, struct tep_event *event, struct tep_print_arg
>  	case TEP_PRINT_DYNAMIC_ARRAY:
>  		/* Without [], we pass the address to the dynamic data */
>  		dynamic_offset_field(tep, arg->dynarray.field, data, size,
> -				     &offset, NULL);
> +				     &offset, &field_size);
>  		if (check_data_offset_size(event, arg->field.name, size,
>  					   offset, field_size)) {
>  			val = (unsigned long)data;


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

end of thread, other threads:[~2022-09-28 21:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-28 21:09 [PATCH] Initialize field_size prior to use Ian Rogers
2022-09-28 21:26 ` 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).