diff options
author | Jack Rosenthal <jrosenth@chromium.org> | 2022-06-27 15:09:12 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-30 18:54:29 +0000 |
commit | dcbc85fa87bb6aab743f6de80602054e5f8f9eed (patch) | |
tree | 88c62ae9075e0d7bb6de440e2aec99a938fc448c /include/console.h | |
parent | 7766e8c75bf4af59b9cbc8216e5b8ebbbc5eff7c (diff) | |
download | chrome-ec-dcbc85fa87bb6aab743f6de80602054e5f8f9eed.tar.gz |
include/console.h: Format with clang-format
BUG=b:236386294
BRANCH=none
TEST=none
Change-Id: I5430e033cc89107860670fae0a2bab5596fabcbc
Signed-off-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3730234
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'include/console.h')
-rw-r--r-- | include/console.h | 94 |
1 files changed, 44 insertions, 50 deletions
diff --git a/include/console.h b/include/console.h index 457d24cc95..addee30386 100644 --- a/include/console.h +++ b/include/console.h @@ -54,10 +54,9 @@ struct hex_buffer_params { uint16_t size; }; -#define HEX_BUF(_buffer, _size) (&(const struct hex_buffer_params){ \ - .buffer = (_buffer), \ - .size = (_size) \ -}) +#define HEX_BUF(_buffer, _size) \ + (&(const struct hex_buffer_params){ .buffer = (_buffer), \ + .size = (_size) }) /* * Define parameters to printing in binary: the value to print, and the number @@ -69,10 +68,9 @@ struct binary_print_params { uint8_t count; }; -#define BINARY_VALUE(_value, _count) (&(const struct binary_print_params){ \ - .value = (_value), \ - .count = (_count) \ -}) +#define BINARY_VALUE(_value, _count) \ + (&(const struct binary_print_params){ .value = (_value), \ + .count = (_count) }) #define PRINTF_TIMESTAMP_NOW NULL @@ -94,7 +92,7 @@ struct console_command { }; /* Flag bits for when CONFIG_CONSOLE_COMMAND_FLAGS is enabled */ -#define CMD_FLAG_RESTRICTED 0x00000001 +#define CMD_FLAG_RESTRICTED 0x00000001 /* The default .flags value can be overridden in board.h */ #ifndef CONFIG_CONSOLE_COMMAND_FLAGS_DEFAULT @@ -116,19 +114,19 @@ static inline int console_is_restricted(void) /* Console channels */ enum console_channel { - #define CONSOLE_CHANNEL(enumeration, string) enumeration, - #include "console_channel.inc" - #undef CONSOLE_CHANNEL +#define CONSOLE_CHANNEL(enumeration, string) enumeration, +#include "console_channel.inc" +#undef CONSOLE_CHANNEL /* Channel count; not itself a channel */ CC_CHANNEL_COUNT }; /* Mask in channel_mask for a particular channel */ -#define CC_MASK(channel) (1U << (channel)) +#define CC_MASK(channel) (1U << (channel)) /* Mask to use to enable all channels */ -#define CC_ALL 0xffffffffU +#define CC_ALL 0xffffffffU /** * Enable a console channel by name @@ -178,8 +176,8 @@ int cputs(enum console_channel channel, const char *outstr); * * @return non-zero if output was truncated. */ -__attribute__((__format__(__printf__, 2, 3))) -int cprintf(enum console_channel channel, const char *format, ...); +__attribute__((__format__(__printf__, 2, 3))) int +cprintf(enum console_channel channel, const char *format, ...); /** * Print formatted output with timestamp. This is like: @@ -190,8 +188,8 @@ int cprintf(enum console_channel channel, const char *format, ...); * * @return non-zero if output was truncated. */ -__attribute__((__format__(__printf__, 2, 3))) -int cprints(enum console_channel channel, const char *format, ...); +__attribute__((__format__(__printf__, 2, 3))) int +cprints(enum console_channel channel, const char *format, ...); /** * Flush the console output for all channels. @@ -205,8 +203,8 @@ void cflush(void); #define ccputs(outstr) cputs(CC_COMMAND, outstr) /* gcc allows variable arg lists in macros; see * http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html */ -#define ccprintf(format, args...) cprintf(CC_COMMAND, format, ## args) -#define ccprints(format, args...) cprints(CC_COMMAND, format, ## args) +#define ccprintf(format, args...) cprintf(CC_COMMAND, format, ##args) +#define ccprints(format, args...) cprints(CC_COMMAND, format, ##args) /** * Called by UART when a line of input is pending. @@ -227,45 +225,41 @@ void console_has_input(void); * @param flags Per-command flags, if needed. */ #if !defined(HAS_TASK_CONSOLE) && !defined(CONFIG_ZEPHYR) -#define DECLARE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \ - static int (ROUTINE)(int argc, char **argv) __attribute__((unused)) -#define DECLARE_SAFE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \ - static int (ROUTINE)(int argc, char **argv) __attribute__((unused)) +#define DECLARE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \ + static int(ROUTINE)(int argc, char **argv) __attribute__((unused)) +#define DECLARE_SAFE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \ + static int(ROUTINE)(int argc, char **argv) __attribute__((unused)) #define DECLARE_CONSOLE_COMMAND_FLAGS(NAME, ROUTINE, ARGDESC, HELP, FLAGS) \ - static int (ROUTINE)(int argc, char **argv) __attribute__((unused)) + static int(ROUTINE)(int argc, char **argv) __attribute__((unused)) #elif defined(HAS_TASK_CONSOLE) /* We always provde help args, but we may discard them to save space. */ #if defined(CONFIG_CONSOLE_CMDHELP) -#define _HELP_ARGS(A, H) \ - .argdesc = A, \ - .help = H, +#define _HELP_ARGS(A, H) .argdesc = A, .help = H, #else #define _HELP_ARGS(A, H) #endif /* We may or may not have a .flags field */ #ifdef CONFIG_CONSOLE_COMMAND_FLAGS -#define _FLAG_ARGS(F) \ - .flags = F, +#define _FLAG_ARGS(F) .flags = F, #else #define _FLAG_ARGS(F) #endif /* This macro takes all possible args and discards the ones we don't use */ -#define _DCL_CON_CMD_ALL(NAME, ROUTINE, ARGDESC, HELP, FLAGS) \ - static int (ROUTINE)(int argc, char **argv); \ - static const char __con_cmd_label_##NAME[] = #NAME; \ - _STATIC_ASSERT(sizeof(__con_cmd_label_##NAME) < 16, \ - "command name '" #NAME "' is too long"); \ - const struct console_command __keep __no_sanitize_address \ - __con_cmd_##NAME \ - __attribute__((section(".rodata.cmds." #NAME))) = \ - { .name = __con_cmd_label_##NAME, \ - .handler = ROUTINE, \ - _HELP_ARGS(ARGDESC, HELP) \ - _FLAG_ARGS(FLAGS) \ - } +#define _DCL_CON_CMD_ALL(NAME, ROUTINE, ARGDESC, HELP, FLAGS) \ + static int(ROUTINE)(int argc, char **argv); \ + static const char __con_cmd_label_##NAME[] = #NAME; \ + _STATIC_ASSERT(sizeof(__con_cmd_label_##NAME) < 16, \ + "command name '" #NAME "' is too long"); \ + const struct console_command __keep __no_sanitize_address \ + __con_cmd_##NAME \ + __attribute__((section(".rodata.cmds." #NAME))) = { \ + .name = __con_cmd_label_##NAME, \ + .handler = ROUTINE, \ + _HELP_ARGS(ARGDESC, HELP) _FLAG_ARGS(FLAGS) \ + } /* * If the .flags field exists, we can use this to specify its value. If not, @@ -275,8 +269,8 @@ void console_has_input(void); _DCL_CON_CMD_ALL(NAME, ROUTINE, ARGDESC, HELP, FLAGS) /* This works as before, for the same reason. */ -#define DECLARE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \ - _DCL_CON_CMD_ALL(NAME, ROUTINE, ARGDESC, HELP, \ +#define DECLARE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \ + _DCL_CON_CMD_ALL(NAME, ROUTINE, ARGDESC, HELP, \ CONFIG_CONSOLE_COMMAND_FLAGS_DEFAULT) /* @@ -284,11 +278,11 @@ void console_has_input(void); * the command is never restricted. BE CAREFUL! You should only use this for * commands that either do nothing or that do only safe things. */ -#define DECLARE_SAFE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \ - _DCL_CON_CMD_ALL(NAME, ROUTINE, ARGDESC, HELP, \ - (CONFIG_CONSOLE_COMMAND_FLAGS_DEFAULT & \ +#define DECLARE_SAFE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \ + _DCL_CON_CMD_ALL(NAME, ROUTINE, ARGDESC, HELP, \ + (CONFIG_CONSOLE_COMMAND_FLAGS_DEFAULT & \ ~CMD_FLAG_RESTRICTED)) -#endif /* HAS_TASK_CONSOLE */ +#endif /* HAS_TASK_CONSOLE */ -#endif /* __CROS_EC_CONSOLE_H */ +#endif /* __CROS_EC_CONSOLE_H */ |