Skip to content

(master) kdrive: parentheses around macro argument symbols#2940

Open
metux wants to merge 1 commit into
masterfrom
pr/master-kdrive-parentheses-around-macro-argument-symbols-_2026-06-09_13-57-03
Open

(master) kdrive: parentheses around macro argument symbols#2940
metux wants to merge 1 commit into
masterfrom
pr/master-kdrive-parentheses-around-macro-argument-symbols-_2026-06-09_13-57-03

Conversation

@metux

@metux metux commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

For safety, add extra parantheses on each used macro argument.
In most cases not strictly necessary, but better have some strict
and automatically enforcable policy here than wasting time on
judging individual cases.

Signed-off-by: Enrico Weigelt, metux IT consult info@metux.net

For safety, add extra parantheses on each used macro argument.
In most cases not strictly necessary, but better have some strict
and automatically enforcable policy here than wasting time on
judging individual cases.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
@metux metux self-assigned this Jun 9, 2026
@metux metux requested a review from a team June 9, 2026 11:57
Comment thread hw/kdrive/src/kdrive.h
dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, v)
#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, (v))
#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv((pScreen))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parentheses already serve as parentheses.

#define OFF(x) ((x)%BITS_PER_LONG)
#define LONG(x) ((x)/BITS_PER_LONG)
#define BIT(x) (1 << OFF(x))
#define BIT(x) (1 << OFF((x)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function/Macro parentheses already serve as parentheses.

Comment thread hw/kdrive/src/kinput.c
#endif

#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
#define AtomFromName(x) MakeAtom((x), strlen((x)), 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function/Macro parentheses already serve as parentheses.

Comment thread hw/kdrive/src/kinput.c
}

#define KdScreenOrigin(pScreen) (&(KdGetScreenPriv(pScreen)->screen->origin))
#define KdScreenOrigin(pScreen) (&(KdGetScreenPriv((pScreen))->screen->origin))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function/Macro parentheses already serve as parentheses.

@stefan11111

Copy link
Copy Markdown
Contributor

@metux Macros are a very fragile thing. You can't just add parentheses treewide and hope for the best.

metux added a commit that referenced this pull request Jun 9, 2026
metux added a commit that referenced this pull request Jun 9, 2026
metux added a commit that referenced this pull request Jun 9, 2026
metux added a commit that referenced this pull request Jun 9, 2026
metux added a commit that referenced this pull request Jun 9, 2026
metux added a commit that referenced this pull request Jun 10, 2026
For safety, add extra parantheses on each used macro argument.
In most cases not strictly necessary, but better have some strict
and automatically enforcable policy here than wasting time on
judging individual cases.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
metux added a commit that referenced this pull request Jun 10, 2026
For safety, add extra parantheses on each used macro argument.
In most cases not strictly necessary, but better have some strict
and automatically enforcable policy here than wasting time on
judging individual cases.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants