lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1239074980.22733.303.camel@macbook.infradead.org>
Date:	Mon, 06 Apr 2009 20:29:40 -0700
From:	David Woodhouse <dwmw2@...radead.org>
To:	torvalds@...ux-foundation.org, Steven Rostedt <rostedt@...dmis.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...e.hu>
Subject: Re: intel-iommu: Add for_each_iommu() and for_each_active_iommu()
 macros

The PROFILE_ALL_BRANCHES option causes us to define if() as a macro...
taking precisely one argument. This causes a build failure if the
condition is actually a comma expression -- 'if (a(), b)'.

This patch turns the if() macro into a varargs macro which copes with a
comma expression as its 'arguments'.

Signed-off-by: David Woodhouse <David.Woodhouse@...el.com>
Acked-by: Steven Rostedt <rostedt@...dmis.org>

---
Some might argue that I shouldn't have been using if(a,b) in the first
place, but in my defence it _should_ have worked, and it was less ugly
than the original. I did this:

#define for_each_active_iommu(i, drhd)                                  \
        list_for_each_entry(drhd, &dmar_drhd_units, list)               \
                if (i=drhd->iommu, drhd->ignored) {} else

... instead of what I was originally given, which was (with the first
three macros added to list.h as a generic facility)...

#define list_first_entry_selected(pos, head, member, selector)		  \
	pos = list_entry((head)->next, typeof(*pos), member),		  \
	pos = ({while (!(selector) && (&pos->member != (head)))		  \
		pos = list_entry(pos->member.next, typeof(*pos), member); \
		pos; })
#define list_next_entry_selected(pos, head, member, selector)		  \
	pos = list_entry(pos->member.next, typeof(*pos), member),	  \
	pos = ({while (!(selector) && (&pos->member != (head)))		  \
		pos = list_entry(pos->member.next, typeof(*pos), member); \
		pos; })
#define list_for_each_entry_selected_do(pos, head, member, selector, to_do) \
	for (list_first_entry_selected(pos, head, member, selector),	    \
		({if (&pos->member != (head)) to_do});			    \
		prefetch(pos->member.next), &pos->member != (head);	    \
		list_next_entry_selected(pos, head, member, selector),	    \
		({if (&pos->member != (head)) to_do}))

#define for_each_active_iommu(i, drhd)					\
	list_for_each_entry_selected_do(drhd, &dmar_drhd_units, list,	\
				!drhd->ignored, {i = drhd->iommu; })

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 6faa7e5..c28d876 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -114,7 +114,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
  * "Define 'is'", Bill Clinton
  * "Define 'if'", Steven Rostedt
  */
-#define if(cond) if (__builtin_constant_p((cond)) ? !!(cond) :		\
+#define if(cond, ...) if (__builtin_constant_p((cond, ## __VA_ARGS__))	\
+			  ? !!(cond, ## __VA_ARGS__) :			\
 	({								\
 		int ______r;						\
 		static struct ftrace_branch_data			\
@@ -125,8 +126,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 				.file = __FILE__,			\
 				.line = __LINE__,			\
 			};						\
-		______r = !!(cond);					\
-		______f.miss_hit[______r]++;					\
+		______r = !!(cond, ## __VA_ARGS__);			\
+		______f.miss_hit[______r]++;				\
 		______r;						\
 	}))
 #endif /* CONFIG_PROFILE_ALL_BRANCHES */

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@...el.com                              Intel Corporation

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ