Skip to content

Commit 36ccd9a

Browse files
authored
warning: macro argument should be enclosed in parentheses [bugprone-macro-parentheses] (#374)
Except where the expansion would be syntactically invalid, for example "goto macroarg;" detection of which is a bug in clang-tidy, so warn it off with a NOLINT...(bugprone-macro-parentheses)
1 parent f6da80f commit 36ccd9a

37 files changed

+385
-380
lines changed

inc/address.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
/**********************************************************************/
3030

3131
/* NOTE: These MACRO should be used for the pointers in LISP SYSOUT */
32-
#define LLSH(datum , n) ((datum )<< n)
33-
#define LRSH(datum , n) ((datum) >> n)
32+
#define LLSH(datum, n) ((datum) << (n))
33+
#define LRSH(datum, n) ((datum) >> (n))
3434

3535
#define HILOC(ptr) (LRSH(((unsigned int)(ptr) & SEGMASK),16))
3636
#define LOLOC(ptr) ((unsigned int)(ptr) & 0x0ffff)

inc/adr68k.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949

5050
/* translate LispPage to 68k address */
51-
#define Addr68k_from_LPAGE(Lisp_page) (Addr68k_from_LADDR((Lisp_page << 8) ))
51+
#define Addr68k_from_LPAGE(Lisp_page) (Addr68k_from_LADDR(((Lisp_page) << 8) ))
5252

5353

5454

inc/arith.h

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,69 +10,71 @@
1010
/************************************************************************/
1111

1212
#define MAX_SMALL 65535 /* == 0x0000FFFF */
13-
#define MIN_SMALL -65536 /* == 0xFFFF0000 */
13+
#define MIN_SMALL (-65536) /* == 0xFFFF0000 */
1414

1515
#define MAX_FIXP 2147483647 /* == 0x7FFFFFFF */
16-
#define MIN_FIXP -2147483648 /* == 0x80000000 */
16+
#define MIN_FIXP (-2147483648) /* == 0x80000000 */
1717

1818
#define GetSmalldata(x) \
19-
(((SEGMASK & x) == S_POSITIVE) \
20-
? (0xFFFF & x) \
21-
: (((SEGMASK & x) == S_NEGATIVE) ? (0xFFFF0000 | x) : error("Not smallp address")))
19+
(((SEGMASK & (x)) == S_POSITIVE) \
20+
? (0xFFFF & (x)) \
21+
: (((SEGMASK & (x)) == S_NEGATIVE) ? (0xFFFF0000 | (x)) : error("Not smallp address")))
2222

2323
#define GetSmallp(x) \
24-
((0xFFFF0000 & x) ? (((0xFFFF0000 & x) == 0xFFFF0000) ? (S_NEGATIVE | (0xFFFF & x)) \
24+
((0xFFFF0000 & (x)) ? (((0xFFFF0000 & (x)) == 0xFFFF0000) ? (S_NEGATIVE | (0xFFFF & (x))) \
2525
: error("Not Smallp data")) \
26-
: (S_POSITIVE | (0xFFFF & x)))
26+
: (S_POSITIVE | (0xFFFF & (x))))
2727

2828
#define FIXP_VALUE(dest) *((int *)Addr68k_from_LADDR(dest))
2929

3030
#define FLOATP_VALUE(dest) *((float *)Addr68k_from_LADDR(dest))
3131

3232
#define N_GETNUMBER(sour, dest, label) \
3333
do { \
34-
dest = sour; /* access memory once */ \
35-
switch (SEGMASK & dest) { \
36-
case S_POSITIVE: dest = 0xFFFF & (dest); break; \
37-
case S_NEGATIVE: dest = 0xFFFF0000 | (dest); break; \
34+
(dest) = (sour); /* access memory once */ \
35+
switch (SEGMASK & (dest)) { \
36+
case S_POSITIVE: (dest) = 0xFFFF & (dest); break; \
37+
case S_NEGATIVE: (dest) = 0xFFFF0000 | (dest); break; \
3838
default: \
39+
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
3940
if (GetTypeNumber(dest) != TYPE_FIXP) goto label; \
40-
dest = FIXP_VALUE(dest); \
41+
(dest) = FIXP_VALUE(dest); \
4142
} \
4243
} while (0)
4344

4445
#define N_IGETNUMBER(sour, dest, label) \
4546
do { \
46-
dest = sour; /* access memory once */ \
47-
switch (SEGMASK & dest) { \
48-
case S_POSITIVE: dest = 0xFFFF & dest; break; \
49-
case S_NEGATIVE: dest = 0xFFFF0000 | dest; break; \
47+
(dest) = (sour); /* access memory once */ \
48+
switch (SEGMASK & (dest)) { \
49+
case S_POSITIVE: (dest) = 0xFFFF & (dest); break; \
50+
case S_NEGATIVE: (dest) = 0xFFFF0000 | (dest); break; \
5051
default: \
5152
switch (GetTypeNumber(dest)) { \
52-
case TYPE_FIXP: dest = FIXP_VALUE(dest); break; \
53+
case TYPE_FIXP: (dest) = FIXP_VALUE(dest); break; \
5354
case TYPE_FLOATP: { \
5455
register float temp; \
5556
temp = FLOATP_VALUE(dest); \
57+
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
5658
if ((temp > ((float)0x7fffffff)) || (temp < ((float)0x80000000))) goto label; \
57-
dest = (int)temp; \
59+
(dest) = (int)temp; \
5860
} break; \
59-
default: goto label; \
61+
default: goto label; /* NOLINT(bugprone-macro-parentheses) */ \
6062
} \
6163
break; \
6264
} \
6365
} while (0)
6466

6567
#define ARITH_SWITCH(arg, result) \
6668
do { \
67-
switch ((int)arg & 0xFFFF0000) { \
68-
case 0: result = (S_POSITIVE | (int)arg); break; \
69-
case 0xFFFF0000: result = (S_NEGATIVE | (0xFFFF & (int)arg)); break; \
69+
switch ((int)(arg) & 0xFFFF0000) { \
70+
case 0: (result) = (S_POSITIVE | (int)(arg)); break; \
71+
case 0xFFFF0000: (result) = (S_NEGATIVE | (0xFFFF & (int)(arg))); break; \
7072
default: { \
7173
register LispPTR *wordp; \
7274
/* arg is FIXP, call createcell */ \
7375
wordp = (LispPTR *)createcell68k(TYPE_FIXP); \
74-
*((int *)wordp) = (int)arg; \
75-
result = (LADDR_from_68k(wordp)); \
76+
*((int *)wordp) = (int)(arg); \
77+
(result) = (LADDR_from_68k(wordp)); \
7678
break; \
7779
} \
7880
} \
@@ -104,9 +106,9 @@
104106

105107
#define N_ARITH_SWITCH(arg) \
106108
do { \
107-
switch (arg & 0xFFFF0000) { \
108-
case 0: return (S_POSITIVE | arg); \
109-
case 0xFFFF0000: return (S_NEGATIVE | (0xFFFF & arg)); \
109+
switch ((arg) & 0xFFFF0000) { \
110+
case 0: return (S_POSITIVE | (arg)); \
111+
case 0xFFFF0000: return (S_NEGATIVE | (0xFFFF & (arg))); \
110112
default: { \
111113
register LispPTR *fixpp; \
112114
/* arg is FIXP, call createcell */ \

inc/bb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
#define B_src_word_in_postloop src32lbit >= dst32lbit
141141

142142
/* VARIABLES */
143-
#define F_num_loop ((dst32lbit + w) >> 5) - 1
143+
#define F_num_loop (((dst32lbit + w) >> 5) - 1)
144144
#define B_num_loop ((w - dst32rbit - 1) > 0) ? ((w - dst32rbit - 1) >> 5) : 0
145145
#define F_preloop_mask ((dst32lbit) ? (~(0xFFFFFFFF << (32 - dst32lbit))) : 0xFFFFFFFF)
146146
#define F_postloop_mask 0xFFFFFFFF << (31 - dst32rbit)

inc/bitblt.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
#define ERROR PIX_SRC
2828

2929
#define PixOperation( SRCTYPE, OPERATION ) \
30-
( SRCTYPE == ERASE ? \
31-
(OPERATION == REPLACE ? PIX_NOT(PIX_SRC) : \
32-
(OPERATION == PAINT ? PIX_NOT(PIX_SRC) | PIX_DST : \
33-
(OPERATION == ERASE ? PIX_NOT(PIX_SRC) & PIX_DST : \
34-
(OPERATION == INVERT ? PIX_NOT(PIX_SRC) ^ PIX_DST : ERROR)))) : \
30+
( (SRCTYPE) == ERASE ? \
31+
((OPERATION) == REPLACE ? PIX_NOT(PIX_SRC) : \
32+
((OPERATION) == PAINT ? PIX_NOT(PIX_SRC) | PIX_DST : \
33+
((OPERATION) == ERASE ? PIX_NOT(PIX_SRC) & PIX_DST : \
34+
((OPERATION) == INVERT ? PIX_NOT(PIX_SRC) ^ PIX_DST : ERROR)))) : \
3535
/* SRCTYPE == INPUT */ \
36-
(OPERATION == REPLACE ? PIX_SRC : \
37-
(OPERATION == PAINT ? PIX_SRC | PIX_DST : \
38-
(OPERATION == ERASE ? PIX_SRC & PIX_DST : \
39-
(OPERATION == INVERT ? PIX_SRC ^ PIX_DST : ERROR)))))
36+
((OPERATION) == REPLACE ? PIX_SRC : \
37+
((OPERATION) == PAINT ? PIX_SRC | PIX_DST : \
38+
((OPERATION) == ERASE ? PIX_SRC & PIX_DST : \
39+
((OPERATION) == INVERT ? PIX_SRC ^ PIX_DST : ERROR)))))
4040

4141

4242
extern DLword *EmMouseX68K, *EmMouseY68K;

inc/cell.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/* On 68010,68000 This Macro does not effect */
3030

3131
#ifdef NEWCDRCODING
32-
#define CARFIELD(x) ((int)x & 0x0fffffff)
32+
#define CARFIELD(x) ((int)(x) & 0x0fffffff)
3333

3434
/* CDR-Codes defs */
3535
#define CDR_ONPAGE 8
@@ -124,7 +124,7 @@ typedef struct freec {
124124

125125
#endif /* BYTESWAP */
126126

127-
#define FREECONS(page, offset) ((freecons *)((DLword *)page + offset))
127+
#define FREECONS(page, offset) ((freecons *)((DLword *)(page) + (offset)))
128128

129129
/************************************************************************/
130130
/* */
@@ -375,20 +375,20 @@ struct cadr_cell {
375375

376376
#else
377377
/* Good for old LITATOMS and new NEW-ATOMs */
378-
#define GetDEFCELL68k(index) \
379-
(((index & SEGMASK) != 0) ? (LispPTR *)(Addr68k_from_LADDR(index) + NEWATOM_DEFN_OFFSET) \
378+
#define GetDEFCELL68k(index) \
379+
((((index) & SEGMASK) != 0) ? (LispPTR *)(Addr68k_from_LADDR(index) + NEWATOM_DEFN_OFFSET) \
380380
: GetDEFCELLlitatom(index))
381381

382-
#define GetVALCELL68k(index) \
383-
(((index & SEGMASK) != 0) ? (LispPTR *)(Addr68k_from_LADDR(index) + NEWATOM_VALUE_OFFSET) \
382+
#define GetVALCELL68k(index) \
383+
((((index) & SEGMASK) != 0) ? (LispPTR *)(Addr68k_from_LADDR(index) + NEWATOM_VALUE_OFFSET) \
384384
: GetVALCELLlitatom(index))
385385

386-
#define GetPnameCell(index) \
387-
(((index & SEGMASK) != 0) ? (LispPTR *)(Addr68k_from_LADDR(index) + NEWATOM_PNAME_OFFSET) \
386+
#define GetPnameCell(index) \
387+
((((index) & SEGMASK) != 0) ? (LispPTR *)(Addr68k_from_LADDR(index) + NEWATOM_PNAME_OFFSET) \
388388
: GetPnameCelllitatom(index))
389389

390-
#define GetPropCell(index) \
391-
(((index & SEGMASK) != 0) ? (LispPTR *)(Addr68k_from_LADDR(index) + NEWATOM_PLIST_OFFSET) \
390+
#define GetPropCell(index) \
391+
((((index) & SEGMASK) != 0) ? (LispPTR *)(Addr68k_from_LADDR(index) + NEWATOM_PLIST_OFFSET) \
392392
: GetPropCelllitatom(index))
393393

394394
/* Good only for old-style LITATOMS */
@@ -420,6 +420,6 @@ struct cadr_cell {
420420
if (GetTypeNumber(parm) != TYPE_LISTP) { \
421421
ERROR_EXIT(tos); \
422422
} else \
423-
dest = cadr(parm); \
423+
(dest) = cadr(parm); \
424424
}
425425
#endif

inc/devif.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ typedef struct
271271
}
272272
#endif /* XWINDOW */
273273

274-
#define OUTER_SB_WIDTH(dsp) (dsp->ScrollBarWidth + 2*(dsp->InternalBorderWidth))
274+
#define OUTER_SB_WIDTH(dsp) ((dsp)->ScrollBarWidth + 2*((dsp)->InternalBorderWidth))
275275

276276
#ifndef min
277277
#define min( a, b ) (((a)<(b))?(a):(b))

inc/display.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ extern DLword *DISP_MAX_Address;
6666
extern DLword *DisplayRegion68k;
6767

6868
#define in_display_segment(baseaddr) \
69-
(((DisplayRegion68k <= baseaddr) && \
70-
(baseaddr <=DISP_MAX_Address)) ? T :NIL )
69+
(((DisplayRegion68k <= (baseaddr)) && \
70+
((baseaddr) <= DISP_MAX_Address)) ? T : NIL )
7171
#endif
7272

7373
#ifdef XWINDOW

inc/gcdata.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
/* IncAllocCnt is called only when *Reclaim_cnt_word != NIL */
4949

5050
#define IncAllocCnt(n) {\
51-
if ((*Reclaim_cnt_word -= n) <= S_POSITIVE) {\
51+
if ((*Reclaim_cnt_word -= (n)) <= S_POSITIVE) { \
5252
/* time for GC */\
5353
Irq_Stk_Check = Irq_Stk_End = 0;\
5454
*Reclaim_cnt_word = S_POSITIVE;\
@@ -57,35 +57,35 @@
5757

5858
/* DecAllocCnt only called when *Reclaim_cnt_word != NIL */
5959

60-
#define DecAllocCnt(n) { *Reclaim_cnt_word += n; }
60+
#define DecAllocCnt(n) { *Reclaim_cnt_word += (n); }
6161

62-
#define FreeLink(link) {\
63-
GETGC(link) = 0;\
64-
GETGC(link+1) = GETGC(HTcoll);\
65-
GETGC(HTcoll) = (link - HTcoll);\
62+
#define FreeLink(link) { \
63+
GETGC(link) = 0; \
64+
GETGC((link)+1) = GETGC(HTcoll); \
65+
GETGC(HTcoll) = ((link) - HTcoll); \
6666
}
6767

6868

6969
/* Given the contents of an HTMAIN or HTCOLL entry,
7070
get the link pointer (i.e., turn off the low bit) */
71-
#define GetLinkptr(entry) (entry & 0x0fffffffe)
71+
#define GetLinkptr(entry) ((entry) & 0x0fffffffe)
7272

7373

7474
#define DelLink(link, prev, entry) { \
75-
if (prev != (GCENTRY *)0) \
75+
if ((prev) != (GCENTRY *)0) \
7676
{ \
77-
GETGC((GCENTRY *)prev + 1) = GETGC((GCENTRY *)link + 1); \
77+
GETGC((GCENTRY *)(prev) + 1) = GETGC((GCENTRY *)(link) + 1); \
7878
} \
7979
else \
8080
{ \
81-
GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link + 1) | 1; \
81+
GETGC((GCENTRY *)(entry)) = GETGC((GCENTRY *)(link) + 1) | 1; \
8282
} \
83-
FreeLink((GCENTRY *)link); \
84-
link = (GCENTRY *)(HTcoll + GetLinkptr(GETGC((GCENTRY *)entry))); \
85-
if (GETGC((GCENTRY *)link + 1) == 0) \
83+
FreeLink((GCENTRY *)(link)); \
84+
(link) = (GCENTRY *)(HTcoll + GetLinkptr(GETGC((GCENTRY *)(entry)))); \
85+
if (GETGC((GCENTRY *)(link) + 1) == 0) \
8686
{ \
87-
GETGC((GCENTRY *)entry) = GETGC((GCENTRY *)link); \
88-
FreeLink((GCENTRY *)link); \
87+
GETGC((GCENTRY *)(entry)) = GETGC((GCENTRY *)(link)); \
88+
FreeLink((GCENTRY *)(link)); \
8989
} \
9090
}
9191

@@ -104,18 +104,18 @@
104104
#define GCLOOKUPV(ptr, case, val) { \
105105
if (RefCntP(ptr)) { \
106106
if (*Reclaim_cnt_word != NIL) \
107-
val = htfind(ptr, case); \
107+
(val) = htfind((ptr), (case)); \
108108
else \
109-
val = rec_htfind(ptr, case); \
110-
} else val = NIL; \
109+
(val) = rec_htfind((ptr), (case)); \
110+
} else (val) = NIL; \
111111
}
112112

113113
#define REC_GCLOOKUP(ptr, case) { if (RefCntP(ptr)) rec_htfind(ptr, case); }
114114
#define REC_GCLOOKUPV(ptr, case, val) { \
115115
if (RefCntP(ptr)) \
116-
val = rec_htfind(ptr, case); \
116+
(val) = rec_htfind((ptr), (case)); \
117117
else \
118-
val = NIL; \
118+
(val) = NIL; \
119119
}
120120

121121
#define FRPLPTR(old , new) { \

0 commit comments

Comments
 (0)