tracing: typecast sizeof and offsetof to unsigned int
authorSteven Rostedt <srostedt@redhat.com>
Fri, 6 Mar 2009 15:50:53 +0000 (10:50 -0500)
committerSteven Rostedt <srostedt@redhat.com>
Tue, 10 Mar 2009 04:34:03 +0000 (00:34 -0400)
Impact: fix compiler warnings

On x86_64 sizeof and offsetof are treated as long, where as on x86_32
they are int. This patch typecasts them to unsigned int to avoid
one arch giving warnings while the other does not.

Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Steven Rostedt <srostedt@redhat.com>
kernel/trace/trace_events.c
kernel/trace/trace_export.c
kernel/trace/trace_format.h

index 4488d90e75ef693f3c714359fdd4c385a978dcc2..fa32ca32076743534725602a2fb95f82d7eb9253 100644 (file)
@@ -448,8 +448,9 @@ event_available_types_read(struct file *filp, char __user *ubuf, size_t cnt,
 }
 
 #undef FIELD
-#define FIELD(type, name) \
-       #type, #name, offsetof(typeof(field), name), sizeof(field.name)
+#define FIELD(type, name)                                              \
+       #type, #name, (unsigned int)offsetof(typeof(field), name),      \
+               (unsigned int)sizeof(field.name)
 
 static int trace_write_header(struct trace_seq *s)
 {
@@ -457,11 +458,11 @@ static int trace_write_header(struct trace_seq *s)
 
        /* struct trace_entry */
        return trace_seq_printf(s,
-                               "\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
-                               "\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
-                               "\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
-                               "\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
-                               "\tfield:%s %s;\toffset:%lu;\tsize:%lu;\n"
+                               "\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
+                               "\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
+                               "\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
+                               "\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
+                               "\tfield:%s %s;\toffset:%u;\tsize:%u;\n"
                                "\n",
                                FIELD(unsigned char, type),
                                FIELD(unsigned char, flags),
index 0fb7be73e31c1628509728add3fd69fb582e5e84..7162ab49d05d30e44c409c3b1a521c41d85e78f2 100644 (file)
 #include "trace_format.h"
 
 #undef TRACE_FIELD_ZERO_CHAR
-#define TRACE_FIELD_ZERO_CHAR(item)                            \
-       ret = trace_seq_printf(s, "\tfield: char " #item ";\t"  \
-                              "offset:%lu;\tsize:0;\n",        \
-                              offsetof(typeof(field), item));  \
-       if (!ret)                                               \
+#define TRACE_FIELD_ZERO_CHAR(item)                                    \
+       ret = trace_seq_printf(s, "\tfield: char " #item ";\t"          \
+                              "offset:%u;\tsize:0;\n",                 \
+                              (unsigned int)offsetof(typeof(field), item)); \
+       if (!ret)                                                       \
                return 0;
 
 
index 03f9a4c165caa9a427fb05572ff3d3e585b892fa..97e59a9c82ea48411dfe704bf6ff883f820c8811 100644 (file)
@@ -22,9 +22,9 @@
 #undef TRACE_FIELD
 #define TRACE_FIELD(type, item, assign)                                        \
        ret = trace_seq_printf(s, "\tfield:" #type " " #item ";\t"      \
-                              "offset:%lu;\tsize:%lu;\n",              \
-                              offsetof(typeof(field), item),           \
-                              sizeof(field.item));                     \
+                              "offset:%u;\tsize:%u;\n",                \
+                              (unsigned int)offsetof(typeof(field), item), \
+                              (unsigned int)sizeof(field.item));       \
        if (!ret)                                                       \
                return 0;
 
@@ -32,9 +32,9 @@
 #undef TRACE_FIELD_SPECIAL
 #define TRACE_FIELD_SPECIAL(type_item, item, cmd)                      \
        ret = trace_seq_printf(s, "\tfield special:" #type_item ";\t"   \
-                              "offset:%lu;\tsize:%lu;\n",              \
-                              offsetof(typeof(field), item),           \
-                              sizeof(field.item));                     \
+                              "offset:%u;\tsize:%u;\n",                \
+                              (unsigned int)offsetof(typeof(field), item), \
+                              (unsigned int)sizeof(field.item));       \
        if (!ret)                                                       \
                return 0;