* [PATCH] Add parentheses to trace_do_casts macro
@ 2007-03-17 20:54 Michael Vrable
2007-03-17 23:41 ` Mark Williamson
0 siblings, 1 reply; 2+ messages in thread
From: Michael Vrable @ 2007-03-17 20:54 UTC (permalink / raw)
To: xen-devel
# HG changeset patch
# User Michael Vrable <mvrable@cs.ucsd.edu>
# Date 1174163889 25200
# Node ID e3b3abd0ee933833e4a20a048de35954675a4ad1
# Parent 98eacf1b075cc8bb2ed9136a0ca381840b8d7ae2
Add parentheses to trace_do_casts macro.
The arguments to this macro didn't have parentheses around them where
they were used. If a call to a TRACE macro included an expression as an
argument, the cast to (unsigned long) could bind to just part of the
expression and lead to unexpected results.
Signed-off-by: Michael Vrable <mvrable@cs.ucsd.edu>
diff -r 98eacf1b075c -r e3b3abd0ee93 xen/include/xen/trace.h
--- a/xen/include/xen/trace.h Sat Mar 17 12:24:32 2007 +0000
+++ b/xen/include/xen/trace.h Sat Mar 17 13:38:09 2007 -0700
@@ -41,11 +41,11 @@ void trace(u32 event, unsigned long d1,
do { \
if ( unlikely(tb_init_done) ) \
trace(e, \
- (unsigned long)d1, \
- (unsigned long)d2, \
- (unsigned long)d3, \
- (unsigned long)d4, \
- (unsigned long)d5); \
+ (unsigned long)(d1), \
+ (unsigned long)(d2), \
+ (unsigned long)(d3), \
+ (unsigned long)(d4), \
+ (unsigned long)(d5)); \
} while ( 0 )
/* Convenience macros for calling the trace function. */
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Add parentheses to trace_do_casts macro
2007-03-17 20:54 [PATCH] Add parentheses to trace_do_casts macro Michael Vrable
@ 2007-03-17 23:41 ` Mark Williamson
0 siblings, 0 replies; 2+ messages in thread
From: Mark Williamson @ 2007-03-17 23:41 UTC (permalink / raw)
To: xen-devel; +Cc: Michael Vrable
ACK.
Nice catch - guess when I wrote that it hadn't occurred to me that people
might be using expressions in trace macros, but it certainly should be a
valid thing to do.
Cheers,
Mark
On Saturday 17 March 2007 20:54, Michael Vrable wrote:
> # HG changeset patch
> # User Michael Vrable <mvrable@cs.ucsd.edu>
> # Date 1174163889 25200
> # Node ID e3b3abd0ee933833e4a20a048de35954675a4ad1
> # Parent 98eacf1b075cc8bb2ed9136a0ca381840b8d7ae2
> Add parentheses to trace_do_casts macro.
>
> The arguments to this macro didn't have parentheses around them where
> they were used. If a call to a TRACE macro included an expression as an
> argument, the cast to (unsigned long) could bind to just part of the
> expression and lead to unexpected results.
>
> Signed-off-by: Michael Vrable <mvrable@cs.ucsd.edu>
>
> diff -r 98eacf1b075c -r e3b3abd0ee93 xen/include/xen/trace.h
> --- a/xen/include/xen/trace.h Sat Mar 17 12:24:32 2007 +0000
> +++ b/xen/include/xen/trace.h Sat Mar 17 13:38:09 2007 -0700
> @@ -41,11 +41,11 @@ void trace(u32 event, unsigned long d1,
> do { \
> if ( unlikely(tb_init_done) ) \
> trace(e, \
> - (unsigned long)d1, \
> - (unsigned long)d2, \
> - (unsigned long)d3, \
> - (unsigned long)d4, \
> - (unsigned long)d5); \
> + (unsigned long)(d1), \
> + (unsigned long)(d2), \
> + (unsigned long)(d3), \
> + (unsigned long)(d4), \
> + (unsigned long)(d5)); \
> } while ( 0 )
>
> /* Convenience macros for calling the trace function. */
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xensource.com
> http://lists.xensource.com/xen-devel
--
Dave: Just a question. What use is a unicyle with no seat? And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-03-17 23:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-17 20:54 [PATCH] Add parentheses to trace_do_casts macro Michael Vrable
2007-03-17 23:41 ` Mark Williamson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.