Re: [PATCH] fbcon: introduce for_each_registered_fb() helper

From
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date
2018-06-29 16:20:38
Also in
dri-devel, lkml
Reply to
Yisheng Xie, 2018-06-28
On Fri, 2018-06-29 at 00:20 +0800, Yisheng Xie wrote:
Following pattern is often used:

 for (i = 0; i < FB_MAX; i++) {
        if (registered_fb[i]) {
                ...
        }
 }

Therefore, as Andy's suggestion, for_each_registered_fb() helper can
Suggested-by then ?
be introduced to make the code easier to read and write by reducing
indentation level. It also saves few lines of code in each occurrence.

This patch convert all part here at the same time.
LGTM except macro implementation. That's why I have mentioned
for_each_pci_bridge() to look at.
quoted hunk ↗ jump to hunk
+#define for_each_registered_fb(i)		\
+	for (i = 0; i < FB_MAX; i++)		\
+		if (registered_fb[i])
+
This needs to be protected against nested conditionals.
Otherwise compiler issues a warning and even may generate wrong code.

-- 
Andy Shevchenko [off-list ref]
Intel Finland Oy
Thread (7 messages) 7 messages, 5 authors, last reply 2018-07-02
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help