Apply on top of Stephen's serie [1-4]. Compile ok.
Style: separate data from code.
net/irda/irlan/irlan_filter.c | 34 ++++++++++++++++++++--------------
1 files changed, 20 insertions(+), 14 deletions(-)
diff -puN net/irda/irlan/irlan_filter.c~irlan-fr-0 net/irda/irlan/irlan_filter.c
--- linux-2.6.0-test3/net/irda/irlan/irlan_filter.c~irlan-fr-0 Wed Aug 20
00:07:37 2003
+++ linux-2.6.0-test3-fr/net/irda/irlan/irlan_filter.c Wed Aug 20 00:18:50 2003
@@ -218,23 +218,29 @@ void irlan_check_command_param(struct ir
*
*/
#ifdef CONFIG_PROC_FS
+#define MASK2STR(m,s) { .mask = m, .str = s }
+
void irlan_print_filter(struct seq_file *seq, int filter_type)
{
- if (filter_type & IRLAN_DIRECTED)
- seq_printf(seq, "%s", "DIRECTED ");
- if (filter_type & IRLAN_FUNCTIONAL)
- seq_printf(seq, "%s", "FUNCTIONAL ");
- if (filter_type & IRLAN_GROUP)
- seq_printf(seq, "%s", "GROUP ");
- if (filter_type & IRLAN_MAC_FRAME)
- seq_printf(seq, "%s", "MAC_FRAME ");
- if (filter_type & IRLAN_MULTICAST)
- seq_printf(seq, "%s", "MULTICAST ");
- if (filter_type & IRLAN_BROADCAST)
- seq_printf(seq, "%s", "BROADCAST ");
- if (filter_type & IRLAN_IPX_SOCKET)
- seq_printf(seq, "%s", "IPX_SOCKET");
+ static struct {
+ int mask;
+ const char *str;
+ } filter_mask2str[] = {
+ MASK2STR(IRLAN_DIRECTED, "DIRECTED"),
+ MASK2STR(IRLAN_FUNCTIONAL, "FUNCTIONAL"),
+ MASK2STR(IRLAN_GROUP, "GROUP"),
+ MASK2STR(IRLAN_MAC_FRAME, "MAC_FRAME"),
+ MASK2STR(IRLAN_MULTICAST, "MULTICAST"),
+ MASK2STR(IRLAN_BROADCAST, "BROADCAST"),
+ MASK2STR(IRLAN_IPX_SOCKET, "IPX_SOCKET"),
+ MASK2STR(0, NULL)
+ }, *p;
+ for (p = filter_mask2str; p->str; p++) {
+ if (filter_type & p->mask)
+ seq_printf(seq, "%s ", p->str);
+ }
seq_putc(seq, '\n');
}
+#undef MASK2STR
#endif
_
|