Skip to contentSkip to conversation

trace/function-graph: Fix build warning on 32-bit

PATCH New Borislav Petkov 2 participants 3 messages Sep 29, 2010 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace/function-graph: Fix build warning on 32-bit

Fix

kernel/trace/trace_functions_graph.c: In function ‘trace_print_graph_duration’:
kernel/trace/trace_functions_graph.c:652: warning: comparison of distinct pointer types lacks a cast

when building 36-rc6 on a 32-bit due to the strict type check failing in the min() macro.

---
 kernel/trace/trace_functions_graph.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
kernel/trace/trace_functions_graph.c +4 -2
index 6f23369..4eab958 100644
@@ -649,8 +649,10 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
 
 	/* Print nsecs (we don't want to exceed 7 numbers) */
 	if (len < 7) {
-		snprintf(nsecs_str, min(sizeof(nsecs_str), 8UL - len), "%03lu",
-			 nsecs_rem);
+		unsigned long slen = min_t(unsigned long, sizeof(nsecs_str),
+							  8UL - len);
+
+		snprintf(nsecs_str, slen, "%03lu", nsecs_rem);
 		ret = trace_seq_printf(s, ".%s", nsecs_str);
 		if (!ret)
 			return TRACE_TYPE_PARTIAL_LINE;
Signature · 6 lines
1.7.2.3


-- 
Regards/Gruss,
    Boris.
#1 lore raw

PATCH 1/1 trace/function-graph: Fix build warning on 32-bit

Quoted 4 lines

Fix

kernel/trace/trace_functions_graph.c: In function ‘trace_print_graph_duration’:
kernel/trace/trace_functions_graph.c:652: warning: comparison of distinct pointer types lacks a cast

sh*t, I got completely carried away with all that typechecking, take this one instead:

--
From: Borislav Petkov <[email protected]>
Date: Wed, 29 Sep 2010 08:39:43 +0200
Subject: [PATCH] trace/function-graph: Fix build warning on 32-bit
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix

kernel/trace/trace_functions_graph.c: In function ‘trace_print_graph_duration’:
kernel/trace/trace_functions_graph.c:652: warning: comparison of distinct pointer types lacks a cast

when building 36-rc6 on a 32-bit due to the strict type check failing in the min() macro.

---
 kernel/trace/trace_functions_graph.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace_functions_graph.c +3 -2
index 6f23369..82306cc 100644
@@ -649,8 +649,9 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
 
 	/* Print nsecs (we don't want to exceed 7 numbers) */
 	if (len < 7) {
-		snprintf(nsecs_str, min(sizeof(nsecs_str), 8UL - len), "%03lu",
-			 nsecs_rem);
+		size_t slen = min_t(size_t, sizeof(nsecs_str), 8UL - len);
+
+		snprintf(nsecs_str, slen, "%03lu", nsecs_rem);
 		ret = trace_seq_printf(s, ".%s", nsecs_str);
 		if (!ret)
 			return TRACE_TYPE_PARTIAL_LINE;
Signature · 5 lines
1.7.2.3

-- 
Regards/Gruss,
    Boris.
#2 lore raw
Quoted 9 lines · Borislav Petkov
Quoted 4 lines

Fix

kernel/trace/trace_functions_graph.c: In function ‘trace_print_graph_duration’:
kernel/trace/trace_functions_graph.c:652: warning: comparison of distinct pointer types lacks a cast

sh*t, I got completely carried away with all that typechecking, take this one instead:

--

Queued, thanks!

Quoted 42 lines

From: Borislav Petkov <[email protected]>
Date: Wed, 29 Sep 2010 08:39:43 +0200
Subject: [PATCH] trace/function-graph: Fix build warning on 32-bit
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix

kernel/trace/trace_functions_graph.c: In function ‘trace_print_graph_duration’:
kernel/trace/trace_functions_graph.c:652: warning: comparison of distinct pointer types lacks a cast

when building 36-rc6 on a 32-bit due to the strict type check failing in the min() macro.

---
 kernel/trace/trace_functions_graph.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace_functions_graph.c +3 -2
index 6f23369..82306cc 100644
@@ -649,8 +649,9 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)
 
 	/* Print nsecs (we don't want to exceed 7 numbers) */
 	if (len < 7) {
-		snprintf(nsecs_str, min(sizeof(nsecs_str), 8UL - len), "%03lu",
-			 nsecs_rem);
+		size_t slen = min_t(size_t, sizeof(nsecs_str), 8UL - len);
+
+		snprintf(nsecs_str, slen, "%03lu", nsecs_rem);
 		ret = trace_seq_printf(s, ".%s", nsecs_str);
 		if (!ret)
 			return TRACE_TYPE_PARTIAL_LINE;
Signature · 5 lines
1.7.2.3

-- 
Regards/Gruss,
    Boris.