Skip to content

Commit 00b37f4

Browse files
committed
Add dummy macros for conditionally defined macros
cppcheck reports "unknownMacro" when a conditionally defined macro is used. This patch adds dummy macros to make code pass the static analytics without other effects. The assignments and increments make cppcheck consider the variables are used to suppress potential reports about uninitialized variables, unused variables, and can-be-constant variables. The pointers with value 1 instead of NULL suppress reports about indirectly getting value of null pointers. Closes #210. Change-Id: Ia8db49c0c71ab82d5da10ce389f57ebb69c99051
1 parent 53aa839 commit 00b37f4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

list.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,9 @@ static inline void list_move_tail(struct list_head *node,
411411
for (entry = list_entry((head)->next, typeof(*entry), member); \
412412
&entry->member != (head); \
413413
entry = list_entry(entry->member.next, typeof(*entry), member))
414+
#else
415+
#define list_for_each_entry(entry, head, member) \
416+
for (entry = (void *) 1; sizeof(struct { int : -1; }); ++(entry))
414417
#endif
415418

416419
/**
@@ -450,6 +453,10 @@ static inline void list_move_tail(struct list_head *node,
450453
safe = list_entry(entry->member.next, typeof(*entry), member); \
451454
&entry->member != (head); entry = safe, \
452455
safe = list_entry(safe->member.next, typeof(*entry), member))
456+
#else
457+
#define list_for_each_entry_safe(entry, safe, head, member) \
458+
for (entry = safe = (void *) 1; sizeof(struct { int : -1; }); \
459+
++(entry), ++(safe))
453460
#endif
454461

455462
#undef __LIST_HAVE_TYPEOF

scripts/checksums

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
db6784ff3917888db4d1dceaa0570d99ed40e762 queue.h
2-
a35ff719849dbe38d903576a332989c5ba7242bf list.h
2+
78828505183bf0444f574c0a33a4a1f5e3231994 list.h
33
3bb0192cee08d165fd597a9f6fbb404533e28fcf scripts/check-commitlog.sh

0 commit comments

Comments
 (0)