Re: [PATCH 2/2][RESEND] tracing: Shrink the size of struct ftrace_event_field

From: Li Zefan
Date: Fri Jul 26 2013 - 23:14:39 EST


>> @@ -111,6 +111,11 @@ static int __trace_define_field(struct list_head *head, const char *type,
>> field->size = size;
>> field->is_signed = is_signed;
>
> I think we should just change is_signed to bool. At least the parameter.
> Or we can make the assignment: field->is_signed = !!is_signed; and nuke
> the check below.
>

Changing field->is_signed to bool won't shrink the size of the struct.
I prefer: field->is_signed = !!is_signed.

>>
>> + WARN_ON(offset >= (1 << 12));
>> + WARN_ON(size >= (1 << 12));
>> + WARN_ON(is_signed >= (1 << 1));
>> + WARN_ON(field->filter_type >= (1 << 4));
>
> Note, the test for field->filter_type is wrong.
>

oops.

> We should make a helper macro:
>
> #define VERIFY_SIZE(type) WARN_ON(type > field->type)
>

Much better!

> and then have:
>
> VERIFY_SIZE(offset);
> VERIFY_SIZE(size);
> VERIFY_SIZE(filter_type);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/