Thread (14 messages) 14 messages, 5 authors, 2014-08-07

Re: [PATCH 7/7] MIPS: GIC: Fix GICBIS macro

From: Ralf Baechle <hidden>
Date: 2014-08-07 22:20:43

On Fri, Jul 18, 2014 at 10:05:29PM +0400, Sergei Shtylyov wrote:
quoted
quoted
quoted
+#define GICBIS(reg, mask, bits)            \
+    do { u32 data;                \
+        GICREAD((reg), data);        \
quoted
quoted
   Why () only around 'reg', not around 'data'?
quoted
Brackets aren't necessary around "data" because it is declared at the start of
the "do" code block, so it can't expand to anything else within that scope.
   Oh, I was not attentive enough, sorry about that... :-<
   However, it makes sense to at least put that declaration at a separate line.
And it's not safe against multiple evaluation of macro arguments.  Imagine
what's going to happen if GICBIS is called as something like

	GICBIS(++a, ++b, c);

That'll expand to:

    do { u32 data;
            GICREAD((++a), data);
            data &= ~(++b);
            data |= ((bits) & (++b));
            GICWRITE((++a), data);
    } while (0)

Paranoia?

  Ralf
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help