WARNING: Possible unwrapped commit description (prefer a maximum 75 chars per line) #6: Added macro functions to make repetitive, nearly identical functions more maintainable via metaprogramming. They generate code in pre-compile, conceptually similar to C++17 if-constexpr. sof/trace, host/trace: rewrote _trace_events using preproc-metaprog. test/cmocka/include/test_group_generator: rewrote macros to not conflict with new ones. CHECK: spaces preferred around that '%' (ctx:WxV) #53: FILE: src/host/trace.c:146: +#define SEQ_STEP_param_procD(i, _) CONCAT(param, i) %d ^ ERROR: Macros with complex values should be enclosed in parentheses #53: FILE: src/host/trace.c:146: +#define SEQ_STEP_param_procD(i, _) CONCAT(param, i) %d CHECK: Macro argument reuse 'arg_count' - possible side-effects? #102: FILE: src/host/trace.c:154: +#define HOST_TRACE_EVENT_NTH_IMPL(arg_count)\ +HOST_TRACE_EVENT_NTH(, arg_count)\ +{\ + char a, b, c;\ + \ + if (test_bench_trace > 0) {\ + /* look up subsystem from trace class table */\ + char *trace_class = strdup(get_trace_class(event >> 24));\ + \ + a = event & 0xff;\ + b = (event >> 8) & 0xff;\ + c = (event >> 16) & 0xff;\ + \ + /* print trace event stderr*/\ + if (!strcmp(trace_class, "value"))\ + fprintf(stderr,\ + "Trace value %d, "QUOTE(SEQ_FROM_0_TO(arg_count, SEQ_STEP_param_procD))"\n"\ + , event SEQ_FROM_0_TO(arg_count, SEQ_STEP_param));\ + else\ + fprintf(stderr,\ + "Trace %s %c%c%c\n"\ + , trace_class, c, b, a);\ + if (trace_class)\ + free(trace_class);\ + }\ +}\ +HOST_TRACE_EVENT_NTH(_mbox_atomic, arg_count)\ +{\ + CONCAT(_trace_event, arg_count)\ + (event SEQ_FROM_0_TO(arg_count,SEQ_STEP_param));\ } WARNING: line over 80 characters #118: FILE: src/host/trace.c:170: + "Trace value %d, "QUOTE(SEQ_FROM_0_TO(arg_count, SEQ_STEP_param_procD))"\n"\ CHECK: Concatenated strings should use spaces between elements #118: FILE: src/host/trace.c:170: + "Trace value %d, "QUOTE(SEQ_FROM_0_TO(arg_count, SEQ_STEP_param_procD))"\n"\ ERROR: space required after that close brace '}' #126: FILE: src/host/trace.c:178: + }\ ERROR: space required after that close brace '}' #127: FILE: src/host/trace.c:179: +}\ ERROR: space required after that ',' (ctx:VxV) #131: FILE: src/host/trace.c:183: + (event SEQ_FROM_0_TO(arg_count,SEQ_STEP_param));\ ^ WARNING: line over 80 characters #211: FILE: src/host/trace.c:199: + * void _trace_event2 (uint32_t log_entry , uint32_t param0 , uint32_t param1) { ... } WARNING: line over 80 characters #212: FILE: src/host/trace.c:200: + * void _trace_event_mbox_atomic2 (uint32_t log_entry , uint32_t param0 , uint32_t param1) { ... } WARNING: line over 80 characters #222: FILE: src/host/trace.c:205: + * void _trace_event3 (uint32_t log_entry , uint32_t param0 , uint32_t param1 , uint32_t param2) { ... } WARNING: line over 80 characters #223: FILE: src/host/trace.c:206: + * void _trace_event_mbox_atomic3 (uint32_t log_entry , uint32_t param0 , uint32_t param1 , uint32_t param2) { ... } ERROR: Macros with complex values should be enclosed in parentheses #272: FILE: src/include/sof/preproc.h:38: +#define PP_NARG_BEFORE_COMPILE(...) IF_ELSE(HAS_ARGS(__VA_ARGS__)) (\ + PP_NARG_BEFORE_COMPILE_(__VA_ARGS__, PP_RSEQ_N()) )\ + (0) ERROR: space prohibited before that close parenthesis ')' #273: FILE: src/include/sof/preproc.h:39: + PP_NARG_BEFORE_COMPILE_(__VA_ARGS__, PP_RSEQ_N()) )\ ERROR: Macros with complex values should be enclosed in parentheses #285: FILE: src/include/sof/preproc.h:51: +#define PP_RSEQ_N() \ + 63, 62, 61, 60, \ + 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \ + 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \ + 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \ + 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \ + 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \ + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 ERROR: Macros with complex values should be enclosed in parentheses #320: FILE: src/include/sof/preproc.h:86: +#define PROBE() ~, 1 ERROR: Macros with complex values should be enclosed in parentheses #345: FILE: src/include/sof/preproc.h:111: +#define _IF_1(...) __VA_ARGS__ _IF_1_ELSE WARNING: space prohibited between function name and open parenthesis '(' #362: FILE: src/include/sof/preproc.h:128: +#define EVAL_128(...) EVAL_64( EVAL_64 (__VA_ARGS__)) ERROR: space prohibited after that open parenthesis '(' #362: FILE: src/include/sof/preproc.h:128: +#define EVAL_128(...) EVAL_64( EVAL_64 (__VA_ARGS__)) WARNING: space prohibited between function name and open parenthesis '(' #363: FILE: src/include/sof/preproc.h:129: +#define EVAL_64(...) EVAL_32( EVAL_32 (__VA_ARGS__)) ERROR: space prohibited after that open parenthesis '(' #363: FILE: src/include/sof/preproc.h:129: +#define EVAL_64(...) EVAL_32( EVAL_32 (__VA_ARGS__)) WARNING: space prohibited between function name and open parenthesis '(' #364: FILE: src/include/sof/preproc.h:130: +#define EVAL_32(...) EVAL_16( EVAL_16 (__VA_ARGS__)) ERROR: space prohibited after that open parenthesis '(' #364: FILE: src/include/sof/preproc.h:130: +#define EVAL_32(...) EVAL_16( EVAL_16 (__VA_ARGS__)) WARNING: space prohibited between function name and open parenthesis '(' #365: FILE: src/include/sof/preproc.h:131: +#define EVAL_16(...) EVAL_8( EVAL_8 (__VA_ARGS__)) ERROR: space prohibited after that open parenthesis '(' #365: FILE: src/include/sof/preproc.h:131: +#define EVAL_16(...) EVAL_8( EVAL_8 (__VA_ARGS__)) WARNING: space prohibited between function name and open parenthesis '(' #366: FILE: src/include/sof/preproc.h:132: +#define EVAL_8(...) EVAL_4( EVAL_4 (__VA_ARGS__)) ERROR: space prohibited after that open parenthesis '(' #366: FILE: src/include/sof/preproc.h:132: +#define EVAL_8(...) EVAL_4( EVAL_4 (__VA_ARGS__)) WARNING: space prohibited between function name and open parenthesis '(' #367: FILE: src/include/sof/preproc.h:133: +#define EVAL_4(...) EVAL_2( EVAL_2 (__VA_ARGS__)) ERROR: space prohibited after that open parenthesis '(' #367: FILE: src/include/sof/preproc.h:133: +#define EVAL_4(...) EVAL_2( EVAL_2 (__VA_ARGS__)) WARNING: space prohibited between function name and open parenthesis '(' #368: FILE: src/include/sof/preproc.h:134: +#define EVAL_2(...) EVAL_1( EVAL_1 (__VA_ARGS__)) ERROR: space prohibited after that open parenthesis '(' #368: FILE: src/include/sof/preproc.h:134: +#define EVAL_2(...) EVAL_1( EVAL_1 (__VA_ARGS__)) ERROR: Macros with complex values should be enclosed in parentheses #426: FILE: src/include/sof/preproc.h:192: +#define DEFER_1(m) m EMPTY() ERROR: Macros with complex values should be enclosed in parentheses #427: FILE: src/include/sof/preproc.h:193: +#define DEFER_2(m) m EMPTY EMPTY()() ERROR: Macros with complex values should be enclosed in parentheses #428: FILE: src/include/sof/preproc.h:194: +#define DEFER_3(m) m EMPTY EMPTY EMPTY()()() ERROR: Macros with complex values should be enclosed in parentheses #429: FILE: src/include/sof/preproc.h:195: +#define DEFER_4(m) m EMPTY EMPTY EMPTY EMPTY()()()() ERROR: Macros with complex values should be enclosed in parentheses #442: FILE: src/include/sof/preproc.h:208: +#define REPEAT(count, macro, ...)\ + WHEN(count)\ + (\ + DEFER(2, REPEAT_INDIRECT) ()\ + (DEC(count), macro, __VA_ARGS__)\ + DEFER(2, macro)\ + (DEC(count), __VA_ARGS__)\ + ) CHECK: Macro argument reuse 'count' - possible side-effects? #442: FILE: src/include/sof/preproc.h:208: +#define REPEAT(count, macro, ...)\ + WHEN(count)\ + (\ + DEFER(2, REPEAT_INDIRECT) ()\ + (DEC(count), macro, __VA_ARGS__)\ + DEFER(2, macro)\ + (DEC(count), __VA_ARGS__)\ + ) CHECK: Macro argument reuse 'macro' - possible side-effects? #442: FILE: src/include/sof/preproc.h:208: +#define REPEAT(count, macro, ...)\ + WHEN(count)\ + (\ + DEFER(2, REPEAT_INDIRECT) ()\ + (DEC(count), macro, __VA_ARGS__)\ + DEFER(2, macro)\ + (DEC(count), __VA_ARGS__)\ + ) ERROR: Macros with complex values should be enclosed in parentheses #461: FILE: src/include/sof/preproc.h:227: +#define MAP_1(m, arg1, ...) m(arg1)\ + MAP_BODY(1, m, __VA_ARGS__) CHECK: Macro argument reuse 'm' - possible side-effects? #461: FILE: src/include/sof/preproc.h:227: +#define MAP_1(m, arg1, ...) m(arg1)\ + MAP_BODY(1, m, __VA_ARGS__) ERROR: Macros with complex values should be enclosed in parentheses #465: FILE: src/include/sof/preproc.h:231: +#define MAP_2(m, arg1, arg2, ...) m(arg1, arg2)\ + MAP_BODY(2, m, __VA_ARGS__) CHECK: Macro argument reuse 'm' - possible side-effects? #465: FILE: src/include/sof/preproc.h:231: +#define MAP_2(m, arg1, arg2, ...) m(arg1, arg2)\ + MAP_BODY(2, m, __VA_ARGS__) ERROR: Macros with complex values should be enclosed in parentheses #469: FILE: src/include/sof/preproc.h:235: +#define MAP_3(m, arg1, arg2, arg3, ...) m(arg1, arg2, arg3)\ + MAP_BODY(3, m, __VA_ARGS__) CHECK: Macro argument reuse 'm' - possible side-effects? #469: FILE: src/include/sof/preproc.h:235: +#define MAP_3(m, arg1, arg2, arg3, ...) m(arg1, arg2, arg3)\ + MAP_BODY(3, m, __VA_ARGS__) CHECK: Macro argument reuse 'm' - possible side-effects? #489: FILE: src/include/sof/preproc.h:255: +#define MAP_AGGREGATE_1(m, aggr, arg1, ...)\ + MAP_AGGREGATE_BODY(1, m, m(aggr, arg1), __VA_ARGS__) CHECK: Macro argument reuse 'm' - possible side-effects? #493: FILE: src/include/sof/preproc.h:259: +#define MAP_AGGREGATE_2(m, aggr, arg1, arg2, ...)\ + MAP_AGGREGATE_BODY(2, m, m(aggr, arg1, arg2), __VA_ARGS__) CHECK: Macro argument reuse 'aggr' - possible side-effects? #497: FILE: src/include/sof/preproc.h:263: +#define MAP_AGGREGATE_BODY(arg_count, m, aggr, ...)\ + IF_ELSE(PP_NARG_BEFORE_COMPILE(__VA_ARGS__))(\ + DEFER(2, _MAP_AGGREGATE)()\ + (arg_count, m, aggr, __VA_ARGS__)\ + )(aggr) ERROR: space required after that ',' (ctx:VxV) #512: FILE: src/include/sof/preproc.h:278: +#define CONCAT_DELIM(delim, x, y) CONCAT(CONCAT(x, delim),y) ^ ERROR: space prohibited before that ',' (ctx:WxW) #519: FILE: src/include/sof/preproc.h:285: +#define SEQ_STEP_param(i, _) , CONCAT(param, i) ^ ERROR: Macros with complex values should be enclosed in parentheses #519: FILE: src/include/sof/preproc.h:285: +#define SEQ_STEP_param(i, _) , CONCAT(param, i) ERROR: space prohibited before that ',' (ctx:WxW) #520: FILE: src/include/sof/preproc.h:286: +#define SEQ_STEP_param_uint32_t(i, _) , uint32_t CONCAT(param, i) ^ ERROR: space prohibited before that ',' (ctx:WxW) #521: FILE: src/include/sof/preproc.h:287: +#define SEQ_STEP_param_uint64_t(i, _) , uint64_t CONCAT(param, i) ^ ERROR: space prohibited before that ',' (ctx:WxW) #522: FILE: src/include/sof/preproc.h:288: +#define SEQ_STEP_param_int32_t( i, _) , int32_t CONCAT(param, i) ^ ERROR: space prohibited after that open parenthesis '(' #522: FILE: src/include/sof/preproc.h:288: +#define SEQ_STEP_param_int32_t( i, _) , int32_t CONCAT(param, i) ERROR: space prohibited before that ',' (ctx:WxW) #523: FILE: src/include/sof/preproc.h:289: +#define SEQ_STEP_param_int64_t( i, _) , int64_t CONCAT(param, i) ^ ERROR: space prohibited after that open parenthesis '(' #523: FILE: src/include/sof/preproc.h:289: +#define SEQ_STEP_param_int64_t( i, _) , int64_t CONCAT(param, i) CHECK: Macro argument reuse 'vararg_count' - possible side-effects? #545: FILE: src/include/sof/preproc.h:311: +#define _FUNC_WITH_VARARGS(prefix, postfix, return_t,\ + fixed_args, vararg_count, vararg_gen_step)\ + return_t CONCAT_SEQ(prefix, postfix, vararg_count)\ + (fixed_args SEQ_FROM_0_TO(vararg_count, vararg_gen_step)) ERROR: Macros with multiple statements should be enclosed in a do - while loop #596: FILE: src/include/sof/trace.h:122: +#define _TRACE_EVENT_NTH_DECLARE_GROUP(arg_count)\ + _TRACE_EVENT_NTH(, arg_count);\ + _TRACE_EVENT_NTH(_mbox, arg_count);\ + _TRACE_EVENT_NTH(_atomic, arg_count);\ + _TRACE_EVENT_NTH(_mbox_atomic, arg_count); CHECK: Macro argument reuse 'arg_count' - possible side-effects? #596: FILE: src/include/sof/trace.h:122: +#define _TRACE_EVENT_NTH_DECLARE_GROUP(arg_count)\ + _TRACE_EVENT_NTH(, arg_count);\ + _TRACE_EVENT_NTH(_mbox, arg_count);\ + _TRACE_EVENT_NTH(_atomic, arg_count);\ + _TRACE_EVENT_NTH(_mbox_atomic, arg_count); WARNING: macros should not use a trailing semicolon #596: FILE: src/include/sof/trace.h:122: +#define _TRACE_EVENT_NTH_DECLARE_GROUP(arg_count)\ + _TRACE_EVENT_NTH(, arg_count);\ + _TRACE_EVENT_NTH(_mbox, arg_count);\ + _TRACE_EVENT_NTH(_atomic, arg_count);\ + _TRACE_EVENT_NTH(_mbox_atomic, arg_count); ERROR: trailing whitespace #602: FILE: src/include/sof/trace.h:128: +/* Declaration of^M$ ERROR: trailing whitespace #603: FILE: src/include/sof/trace.h:129: + * void _trace_event0 (uint32_t log_entry);^M$ ERROR: trailing whitespace #604: FILE: src/include/sof/trace.h:130: + * void _trace_event_mbox0 (uint32_t log_entry);^M$ ERROR: trailing whitespace #605: FILE: src/include/sof/trace.h:131: + * void _trace_event_atomic0 (uint32_t log_entry);^M$ ERROR: trailing whitespace #606: FILE: src/include/sof/trace.h:132: + * void _trace_event_mbox_atomic0(uint32_t log_entry);^M$ ERROR: DOS line endings #607: FILE: src/include/sof/trace.h:133: + */^M$ ERROR: DOS line endings #608: FILE: src/include/sof/trace.h:134: +_TRACE_EVENT_NTH_DECLARE_GROUP(0)^M$ ERROR: DOS line endings #609: FILE: src/include/sof/trace.h:135: +^M$ ERROR: trailing whitespace #610: FILE: src/include/sof/trace.h:136: +/* Declaration of^M$ ERROR: trailing whitespace #611: FILE: src/include/sof/trace.h:137: + * void _trace_event1 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #612: FILE: src/include/sof/trace.h:138: + * void _trace_event_mbox1 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #613: FILE: src/include/sof/trace.h:139: + * void _trace_event_atomic1 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #614: FILE: src/include/sof/trace.h:140: + * void _trace_event_mbox_atomic1(uint32_t log_entry, uint32_t params...);^M$ ERROR: DOS line endings #615: FILE: src/include/sof/trace.h:141: + */^M$ ERROR: DOS line endings #616: FILE: src/include/sof/trace.h:142: +_TRACE_EVENT_NTH_DECLARE_GROUP(1)^M$ ERROR: DOS line endings #617: FILE: src/include/sof/trace.h:143: +^M$ ERROR: trailing whitespace #618: FILE: src/include/sof/trace.h:144: +/* Declaration of^M$ ERROR: trailing whitespace #619: FILE: src/include/sof/trace.h:145: + * void _trace_event2 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #620: FILE: src/include/sof/trace.h:146: + * void _trace_event_mbox2 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #621: FILE: src/include/sof/trace.h:147: + * void _trace_event_atomic2 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #622: FILE: src/include/sof/trace.h:148: + * void _trace_event_mbox_atomic2(uint32_t log_entry, uint32_t params...);^M$ ERROR: DOS line endings #623: FILE: src/include/sof/trace.h:149: + */^M$ ERROR: DOS line endings #624: FILE: src/include/sof/trace.h:150: +_TRACE_EVENT_NTH_DECLARE_GROUP(2)^M$ ERROR: DOS line endings #625: FILE: src/include/sof/trace.h:151: +^M$ ERROR: trailing whitespace #626: FILE: src/include/sof/trace.h:152: +/* Declaration of^M$ ERROR: trailing whitespace #627: FILE: src/include/sof/trace.h:153: + * void _trace_event3 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #628: FILE: src/include/sof/trace.h:154: + * void _trace_event_mbox3 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #629: FILE: src/include/sof/trace.h:155: + * void _trace_event_atomic3 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #630: FILE: src/include/sof/trace.h:156: + * void _trace_event_mbox_atomic3(uint32_t log_entry, uint32_t params...);^M$ ERROR: DOS line endings #631: FILE: src/include/sof/trace.h:157: + */^M$ ERROR: DOS line endings #632: FILE: src/include/sof/trace.h:158: +_TRACE_EVENT_NTH_DECLARE_GROUP(3)^M$ ERROR: DOS line endings #633: FILE: src/include/sof/trace.h:159: +^M$ ERROR: trailing whitespace #634: FILE: src/include/sof/trace.h:160: +/* Declaration of^M$ ERROR: trailing whitespace #635: FILE: src/include/sof/trace.h:161: + * void _trace_event4 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #636: FILE: src/include/sof/trace.h:162: + * void _trace_event_mbox4 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #637: FILE: src/include/sof/trace.h:163: + * void _trace_event_atomic4 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #638: FILE: src/include/sof/trace.h:164: + * void _trace_event_mbox_atomic4(uint32_t log_entry, uint32_t params...);^M$ ERROR: DOS line endings #639: FILE: src/include/sof/trace.h:165: + */^M$ ERROR: DOS line endings #640: FILE: src/include/sof/trace.h:166: +_TRACE_EVENT_NTH_DECLARE_GROUP(4)^M$ ERROR: DOS line endings #641: FILE: src/include/sof/trace.h:167: +^M$ ERROR: trailing whitespace #642: FILE: src/include/sof/trace.h:168: +/* Declaration of^M$ ERROR: trailing whitespace #643: FILE: src/include/sof/trace.h:169: + * void _trace_event5 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #644: FILE: src/include/sof/trace.h:170: + * void _trace_event_mbox5 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #645: FILE: src/include/sof/trace.h:171: + * void _trace_event_atomic5 (uint32_t log_entry, uint32_t params...);^M$ ERROR: trailing whitespace #646: FILE: src/include/sof/trace.h:172: + * void _trace_event_mbox_atomic5(uint32_t log_entry, uint32_t params...);^M$ ERROR: DOS line endings #647: FILE: src/include/sof/trace.h:173: + */^M$ ERROR: space required after that ',' (ctx:VxO) #677: FILE: src/include/sof/trace.h:203: + _log_message(_mbox,, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__) ^ ERROR: space required after that ',' (ctx:BxO) #683: FILE: src/include/sof/trace.h:209: + _log_message(,, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__) ^ ERROR: space required after that ',' (ctx:BxO) #710: FILE: src/include/sof/trace.h:236: + _log_message(,, LOG_LEVEL_CRITICAL, __c, __e, ##__VA_ARGS__) ^ ERROR: Macros with multiple statements should be enclosed in a do - while loop #1310: FILE: src/lib/trace.c:78: +#define _TRACE_EVENT_NTH_IMPL_DT_STEP(i, _)\ + dt[payload_offset + 1 + i] = CONCAT(param, i); CHECK: Macro argument reuse 'i' - possible side-effects? #1310: FILE: src/lib/trace.c:78: +#define _TRACE_EVENT_NTH_IMPL_DT_STEP(i, _)\ + dt[payload_offset + 1 + i] = CONCAT(param, i); WARNING: macros should not use a trailing semicolon #1310: FILE: src/lib/trace.c:78: +#define _TRACE_EVENT_NTH_IMPL_DT_STEP(i, _)\ + dt[payload_offset + 1 + i] = CONCAT(param, i); ERROR: Macros with multiple statements should be enclosed in a do - while loop #1312: FILE: src/lib/trace.c:80: +#define _TRACE_EVENT_NTH_IMPL_T_STEP(i, _)\ + t[payload_offset + 1 + i] = CONCAT(param, i); CHECK: Macro argument reuse 'i' - possible side-effects? #1312: FILE: src/lib/trace.c:80: +#define _TRACE_EVENT_NTH_IMPL_T_STEP(i, _)\ + t[payload_offset + 1 + i] = CONCAT(param, i); WARNING: macros should not use a trailing semicolon #1312: FILE: src/lib/trace.c:80: +#define _TRACE_EVENT_NTH_IMPL_T_STEP(i, _)\ + t[payload_offset + 1 + i] = CONCAT(param, i); CHECK: Macro argument reuse 'is_mbox' - possible side-effects? #1320: FILE: src/lib/trace.c:88: +#define _TRACE_EVENT_NTH_IMPL(is_mbox, is_atomic, arg_count)\ +_TRACE_EVENT_NTH(CONCAT(\ +IF_ELSE(is_mbox)(_mbox)(), /*if is_mbox , append _mbox to function name*/\ +IF_ELSE(is_atomic)(_atomic)()/*if is_atomic, append _atomic to function name*/\ +), arg_count)\ +{\ + const uint32_t msg_size_dwords = MESSAGE_SIZE(arg_count);\ + const uint32_t payload_offset = sizeof(struct log_entry_header)\ + / sizeof(uint32_t);\ + uint32_t dt[MESSAGE_SIZE(arg_count)];\ + IF_ELSE(is_mbox)\ + (\ + volatile uint32_t *t;\ + IF_ELSE(is_atomic)()(unsigned long flags;)\ + )()\ +\ + if (!trace->enable)\ + return;\ +\ + IF_ELSE(is_mbox)\ + (\ + uint64_t time = platform_timer_get(platform_timer);\ + put_header(dt, time);\ + )\ + (\ + put_header(dt, platform_timer_get(platform_timer));\ + )\ +\ + dt[payload_offset] = log_entry;\ + _TRACE_EVENT_NTH_IMPL_DT(arg_count)\ + IF_ELSE(is_atomic)\ + (dtrace_event_atomic)\ + (dtrace_event)\ + ((const char *)dt, sizeof(uint32_t) * msg_size_dwords);\ + IF_ELSE(is_mbox)\ + (\ + IF_ELSE(is_atomic)()(\ + /* send event by mail box too. */\ + spin_lock_irq(&trace->lock, flags);\ + )\ + /* write timestamp and event to trace buffer */\ + t = (volatile uint32_t *)(MAILBOX_TRACE_BASE + trace->pos);\ + trace->pos += sizeof(uint32_t) * msg_size_dwords;\ +\ + if (trace->pos > MAILBOX_TRACE_SIZE\ + - sizeof(uint32_t) * msg_size_dwords)\ + trace->pos = 0;\ +\ + IF_ELSE(is_atomic)()(spin_unlock_irq(&trace->lock, flags);)\ +\ + put_header(t, time);\ + t[payload_offset] = log_entry;\ + _TRACE_EVENT_NTH_IMPL_T(arg_count)\ +\ + /* writeback trace data */\ + dcache_writeback_region\ + ((void *)t, sizeof(uint32_t) * msg_size_dwords);\ + )()\ +} CHECK: Macro argument reuse 'is_atomic' - possible side-effects? #1320: FILE: src/lib/trace.c:88: +#define _TRACE_EVENT_NTH_IMPL(is_mbox, is_atomic, arg_count)\ +_TRACE_EVENT_NTH(CONCAT(\ +IF_ELSE(is_mbox)(_mbox)(), /*if is_mbox , append _mbox to function name*/\ +IF_ELSE(is_atomic)(_atomic)()/*if is_atomic, append _atomic to function name*/\ +), arg_count)\ +{\ + const uint32_t msg_size_dwords = MESSAGE_SIZE(arg_count);\ + const uint32_t payload_offset = sizeof(struct log_entry_header)\ + / sizeof(uint32_t);\ + uint32_t dt[MESSAGE_SIZE(arg_count)];\ + IF_ELSE(is_mbox)\ + (\ + volatile uint32_t *t;\ + IF_ELSE(is_atomic)()(unsigned long flags;)\ + )()\ +\ + if (!trace->enable)\ + return;\ +\ + IF_ELSE(is_mbox)\ + (\ + uint64_t time = platform_timer_get(platform_timer);\ + put_header(dt, time);\ + )\ + (\ + put_header(dt, platform_timer_get(platform_timer));\ + )\ +\ + dt[payload_offset] = log_entry;\ + _TRACE_EVENT_NTH_IMPL_DT(arg_count)\ + IF_ELSE(is_atomic)\ + (dtrace_event_atomic)\ + (dtrace_event)\ + ((const char *)dt, sizeof(uint32_t) * msg_size_dwords);\ + IF_ELSE(is_mbox)\ + (\ + IF_ELSE(is_atomic)()(\ + /* send event by mail box too. */\ + spin_lock_irq(&trace->lock, flags);\ + )\ + /* write timestamp and event to trace buffer */\ + t = (volatile uint32_t *)(MAILBOX_TRACE_BASE + trace->pos);\ + trace->pos += sizeof(uint32_t) * msg_size_dwords;\ +\ + if (trace->pos > MAILBOX_TRACE_SIZE\ + - sizeof(uint32_t) * msg_size_dwords)\ + trace->pos = 0;\ +\ + IF_ELSE(is_atomic)()(spin_unlock_irq(&trace->lock, flags);)\ +\ + put_header(t, time);\ + t[payload_offset] = log_entry;\ + _TRACE_EVENT_NTH_IMPL_T(arg_count)\ +\ + /* writeback trace data */\ + dcache_writeback_region\ + ((void *)t, sizeof(uint32_t) * msg_size_dwords);\ + )()\ +} CHECK: Macro argument reuse 'arg_count' - possible side-effects? #1320: FILE: src/lib/trace.c:88: +#define _TRACE_EVENT_NTH_IMPL(is_mbox, is_atomic, arg_count)\ +_TRACE_EVENT_NTH(CONCAT(\ +IF_ELSE(is_mbox)(_mbox)(), /*if is_mbox , append _mbox to function name*/\ +IF_ELSE(is_atomic)(_atomic)()/*if is_atomic, append _atomic to function name*/\ +), arg_count)\ +{\ + const uint32_t msg_size_dwords = MESSAGE_SIZE(arg_count);\ + const uint32_t payload_offset = sizeof(struct log_entry_header)\ + / sizeof(uint32_t);\ + uint32_t dt[MESSAGE_SIZE(arg_count)];\ + IF_ELSE(is_mbox)\ + (\ + volatile uint32_t *t;\ + IF_ELSE(is_atomic)()(unsigned long flags;)\ + )()\ +\ + if (!trace->enable)\ + return;\ +\ + IF_ELSE(is_mbox)\ + (\ + uint64_t time = platform_timer_get(platform_timer);\ + put_header(dt, time);\ + )\ + (\ + put_header(dt, platform_timer_get(platform_timer));\ + )\ +\ + dt[payload_offset] = log_entry;\ + _TRACE_EVENT_NTH_IMPL_DT(arg_count)\ + IF_ELSE(is_atomic)\ + (dtrace_event_atomic)\ + (dtrace_event)\ + ((const char *)dt, sizeof(uint32_t) * msg_size_dwords);\ + IF_ELSE(is_mbox)\ + (\ + IF_ELSE(is_atomic)()(\ + /* send event by mail box too. */\ + spin_lock_irq(&trace->lock, flags);\ + )\ + /* write timestamp and event to trace buffer */\ + t = (volatile uint32_t *)(MAILBOX_TRACE_BASE + trace->pos);\ + trace->pos += sizeof(uint32_t) * msg_size_dwords;\ +\ + if (trace->pos > MAILBOX_TRACE_SIZE\ + - sizeof(uint32_t) * msg_size_dwords)\ + trace->pos = 0;\ +\ + IF_ELSE(is_atomic)()(spin_unlock_irq(&trace->lock, flags);)\ +\ + put_header(t, time);\ + t[payload_offset] = log_entry;\ + _TRACE_EVENT_NTH_IMPL_T(arg_count)\ +\ + /* writeback trace data */\ + dcache_writeback_region\ + ((void *)t, sizeof(uint32_t) * msg_size_dwords);\ + )()\ +} WARNING: Macros with flow control statements should be avoided #1320: FILE: src/lib/trace.c:88: +#define _TRACE_EVENT_NTH_IMPL(is_mbox, is_atomic, arg_count)\ +_TRACE_EVENT_NTH(CONCAT(\ +IF_ELSE(is_mbox)(_mbox)(), /*if is_mbox , append _mbox to function name*/\ +IF_ELSE(is_atomic)(_atomic)()/*if is_atomic, append _atomic to function name*/\ +), arg_count)\ +{\ + const uint32_t msg_size_dwords = MESSAGE_SIZE(arg_count);\ + const uint32_t payload_offset = sizeof(struct log_entry_header)\ + / sizeof(uint32_t);\ + uint32_t dt[MESSAGE_SIZE(arg_count)];\ + IF_ELSE(is_mbox)\ + (\ + volatile uint32_t *t;\ + IF_ELSE(is_atomic)()(unsigned long flags;)\ + )()\ +\ + if (!trace->enable)\ + return;\ +\ + IF_ELSE(is_mbox)\ + (\ + uint64_t time = platform_timer_get(platform_timer);\ + put_header(dt, time);\ + )\ + (\ + put_header(dt, platform_timer_get(platform_timer));\ + )\ +\ + dt[payload_offset] = log_entry;\ + _TRACE_EVENT_NTH_IMPL_DT(arg_count)\ + IF_ELSE(is_atomic)\ + (dtrace_event_atomic)\ + (dtrace_event)\ + ((const char *)dt, sizeof(uint32_t) * msg_size_dwords);\ + IF_ELSE(is_mbox)\ + (\ + IF_ELSE(is_atomic)()(\ + /* send event by mail box too. */\ + spin_lock_irq(&trace->lock, flags);\ + )\ + /* write timestamp and event to trace buffer */\ + t = (volatile uint32_t *)(MAILBOX_TRACE_BASE + trace->pos);\ + trace->pos += sizeof(uint32_t) * msg_size_dwords;\ +\ + if (trace->pos > MAILBOX_TRACE_SIZE\ + - sizeof(uint32_t) * msg_size_dwords)\ + trace->pos = 0;\ +\ + IF_ELSE(is_atomic)()(spin_unlock_irq(&trace->lock, flags);)\ +\ + put_header(t, time);\ + t[payload_offset] = log_entry;\ + _TRACE_EVENT_NTH_IMPL_T(arg_count)\ +\ + /* writeback trace data */\ + dcache_writeback_region\ + ((void *)t, sizeof(uint32_t) * msg_size_dwords);\ + )()\ +} WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #1332: FILE: src/lib/trace.c:100: + volatile uint32_t *t;\ WARNING: Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst #1361: FILE: src/lib/trace.c:129: + t = (volatile uint32_t *)(MAILBOX_TRACE_BASE + trace->pos);\ WARNING: suspect code indent for conditional statements (16, 16) #1364: FILE: src/lib/trace.c:132: + if (trace->pos > MAILBOX_TRACE_SIZE\ [...] + trace->pos = 0;\ ERROR: Macros with complex values should be enclosed in parentheses #1380: FILE: src/lib/trace.c:148: +#define _TRACE_EVENT_NTH_IMPL_GROUP(arg_count)\ + /* send trace events only to the local trace buffer */\ + _TRACE_EVENT_NTH_IMPL(0, 0, arg_count)\ + _TRACE_EVENT_NTH_IMPL(0, 1, arg_count)\ + /* send trace events to the local trace buffer and the mailbox */\ + _TRACE_EVENT_NTH_IMPL(1, 0, arg_count)\ + _TRACE_EVENT_NTH_IMPL(1, 1, arg_count) CHECK: Macro argument reuse 'arg_count' - possible side-effects? #1380: FILE: src/lib/trace.c:148: +#define _TRACE_EVENT_NTH_IMPL_GROUP(arg_count)\ + /* send trace events only to the local trace buffer */\ + _TRACE_EVENT_NTH_IMPL(0, 0, arg_count)\ + _TRACE_EVENT_NTH_IMPL(0, 1, arg_count)\ + /* send trace events to the local trace buffer and the mailbox */\ + _TRACE_EVENT_NTH_IMPL(1, 0, arg_count)\ + _TRACE_EVENT_NTH_IMPL(1, 1, arg_count) CHECK: Please don't use multiple blank lines #1388: FILE: src/lib/trace.c:156: + + CHECK: Lines should not end with a '(' #1586: FILE: test/cmocka/src/debugability/macros.c:45: + const char *macro_result = CAPTURE(_DECLARE_LOG_ENTRY( WARNING: quoted string split across lines #1589: FILE: test/cmocka/src/debugability/macros.c:48: + const char *should_be_eq = "__attribute__((section(\".static_log.\"" + " \"LOG_LEVEL_CRITICAL\"))) " WARNING: quoted string split across lines #1590: FILE: test/cmocka/src/debugability/macros.c:49: + " \"LOG_LEVEL_CRITICAL\"))) " + "static const struct { uint32_t level; uint32_t component_id; " WARNING: quoted string split across lines #1594: FILE: test/cmocka/src/debugability/macros.c:53: + "uint32_t text_len; const char text[sizeof(\"Message\")]; } " + "log_entry = { 1"; WARNING: quoted string split across lines #1606: FILE: test/cmocka/src/debugability/macros.c:65: + const char *should_be_eq = "{ log_func log_function = (log_func)& " + "_trace_event0; log_function(&log_entry);}"; WARNING: quoted string split across lines #1622: FILE: test/cmocka/src/debugability/macros.c:81: + const char *should_be_eq = "{ log_func log_function = (log_func)& " + "_trace_event1; log_function(&log_entry, param0);}"; WARNING: quoted string split across lines #1638: FILE: test/cmocka/src/debugability/macros.c:97: + const char *should_be_eq = "{ log_func log_function = (log_func)& " + "_trace_event2; log_function(&log_entry, param0, param1);}"; WARNING: line over 80 characters #1654: FILE: test/cmocka/src/debugability/macros.c:113: + "_trace_event3; log_function(&log_entry, param0, param1, param2);}"; WARNING: quoted string split across lines #1654: FILE: test/cmocka/src/debugability/macros.c:113: + const char *should_be_eq = "{ log_func log_function = (log_func)& " + "_trace_event3; log_function(&log_entry, param0, param1, param2);}"; CHECK: Avoid CamelCase: #1666: FILE: test/cmocka/src/debugability/macros.c:125: + const struct CMUnitTest tests[] = { ERROR: space prohibited before that close parenthesis ')' #1731: FILE: test/cmocka/src/lib/preproc/concat.c:46: + int r = CONCAT(A, ); ERROR: space prohibited before that close parenthesis ')' #1758: FILE: test/cmocka/src/lib/preproc/concat.c:73: + int r = CONCAT_SEQ(A, ); CHECK: Please don't use multiple blank lines #1885: FILE: test/cmocka/src/lib/preproc/seq.c:72: + + CHECK: Lines should not end with a '(' #1888: FILE: test/cmocka/src/lib/preproc/seq.c:75: + const char *r = QUOTE( CHECK: Please don't use multiple blank lines #1896: FILE: test/cmocka/src/lib/preproc/seq.c:83: + + CHECK: Lines should not end with a '(' #1899: FILE: test/cmocka/src/lib/preproc/seq.c:86: + const char *r = CAPTURE_PARAMS( CHECK: Lines should not end with a '(' #1909: FILE: test/cmocka/src/lib/preproc/seq.c:96: + const char *r = CAPTURE_PARAMS( WARNING: quoted string split across lines #1915: FILE: test/cmocka/src/lib/preproc/seq.c:102: + assert_string_equal(r, " , " + "uint32_t param0 , " WARNING: quoted string split across lines #1916: FILE: test/cmocka/src/lib/preproc/seq.c:103: + "uint32_t param0 , " + "uint32_t param1 , " WARNING: quoted string split across lines #1917: FILE: test/cmocka/src/lib/preproc/seq.c:104: + "uint32_t param1 , " + "uint32_t param2"); total: 88 errors, 31 warnings, 27 checks, 1967 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. NOTE: Whitespace errors detected. You may wish to use scripts/cleanpatch or scripts/cleanfile 0001-debugability-macro-metaprogramming-refactor.patch has style problems, please review. NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.