Skip to content

RFC Fix parentheses around macro parameter use in headers

Mathieu Desnoyers linux-block lkml netdev rcu 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest13 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13rcu: rcupdate.h: Fix parentheses around macro parameter useinclude/linux/rcupdate.h+23 -230 replies
2/13rculist.h: Fix parentheses around macro pointer parameter useinclude/linux/rculist.h+14 -140 replies
3/13rculist_nulls.h: Add parentheses around macro pointer parameter useinclude/linux/rculist_nulls.h+2 -20 replies
4/13rculist_bl.h: Fix parentheses around macro pointer parameter useinclude/linux/rculist_bl.h+3 -30 replies
5/13list.h: Fix parentheses around macro pointer parameter useinclude/linux/list.h+27 -274 replies
6/13list_nulls.h: Fix parentheses around macro pointer parameter useinclude/linux/list_nulls.h+4 -40 replies
7/13list_bl.h: Fix parentheses around macro pointer parameter useinclude/linux/list_bl.h+6 -60 replies
8/13llist.h: Fix parentheses around macro pointer parameter useinclude/linux/llist.h+7 -70 replies
9/13klist.h: Fix parentheses around macro parameter useinclude/linux/klist.h+4 -40 replies
10/13resource_ext.h: Remove useless parentheses around macro parametersinclude/linux/resource_ext.h+3 -30 replies
11/13netdevice.h: Fix parentheses around macro parameter useinclude/linux/netdevice.h+6 -62 replies
12/13blk-mq.h: Fix parentheses around macro parameter useinclude/linux/blk-mq.h+19 -199 replies
13/13bio.h: Fix parentheses around macro parameter useinclude/linux/bio.h+11 -110 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/13] Fix parentheses around macro parameter use in headers

I tried to look at various list and list user headers in the kernel tree to figure out what the proper parentheses pattern should be around macro parameter use for new code, and it turns out that the current code base lacks consistency.

This is not an exhaustive change of all public kernel headers, but at least it is a start, updating those which are implementing or using kernel lists.

The basic rules followed here are:

- Use parentheses around arguments which are rvalues, except when those are expressions between commas "," used as arguments to functions or other macros, or surrounded by brackets "[]".
- Do not use parentheses around arguments which are lvalues.

For consistency, when a macro argument is used both as an lvalue and as an rvalue within the macro, use the parentheses rules applying to each of the context: with parentheses for rvalue, without parentheses for lvalue.

Mathieu Desnoyers (13):
rcu: rcupdate.h: Fix parentheses around macro parameter use rculist.h: Fix parentheses around macro pointer parameter use rculist_nulls.h: Add parentheses around macro pointer parameter use rculist_bl.h: Fix parentheses around macro pointer parameter use list.h: Fix parentheses around macro pointer parameter use list_nulls.h: Fix parentheses around macro pointer parameter use list_bl.h: Fix parentheses around macro pointer parameter use llist.h: Fix parentheses around macro pointer parameter use klist.h: Fix parentheses around macro parameter use resource_ext.h: Remove useless parentheses around macro parameters netdevice.h: Fix parentheses around macro parameter use blk-mq.h: Fix parentheses around macro parameter use bio.h: Fix parentheses around macro parameter use

 include/linux/bio.h           | 22 +++++++-------
 include/linux/blk-mq.h        | 38 ++++++++++++------------
 include/linux/klist.h         |  8 +++---
 include/linux/list.h          | 54 +++++++++++++++++------------------
 include/linux/list_bl.h       | 12 ++++----
 include/linux/list_nulls.h    |  8 +++---
 include/linux/llist.h         | 14 ++++-----
 include/linux/netdevice.h     | 12 ++++----
 include/linux/rculist.h       | 28 +++++++++---------
 include/linux/rculist_bl.h    |  6 ++--
 include/linux/rculist_nulls.h |  4 +--
 include/linux/rcupdate.h      | 46 ++++++++++++++---------------
 include/linux/resource_ext.h  |  6 ++--
 13 files changed, 129 insertions(+), 129 deletions(-)
Signature · 1 line
2.25.1