Skip to content
Permalink
Browse files

shell: Initialize va_list variables portably.

The structure of the va_list type is architecture-dependent, and it
doesn't seem possible to initialize va_list variables in a portable way
(except by using va_start()). In particular, the x86_64 ABI defines the
type like this:

    typedef struct {
        unsigned int gp_offset;
        unsigned int fp_offset;
        void *overflow_arg_area;
        void *reg_save_area;
    } va_list[1];

Fortunately, the va_start() macro expects an uninitialized va_list
variable, so we can simply remove the initializers to make the code
portable.

Signed-off-by: Jakob Olesen <jolesen@fb.com>
  • Loading branch information...
stoklund authored and carlescufi committed Jun 6, 2019
1 parent 69de620 commit 71260d88d5d1da577c50f40015ddbfd2c74d7eb1
Showing with 2 additions and 2 deletions.
  1. +1 −1 subsys/shell/shell.c
  2. +1 −1 subsys/shell/shell_ops.c
@@ -1327,7 +1327,7 @@ void shell_fprintf(const struct shell *shell, enum shell_vt100_color color,
__ASSERT_NO_MSG(shell->fprintf_ctx);
__ASSERT_NO_MSG(fmt);

va_list args = { 0 };
va_list args;

k_mutex_lock(&shell->ctx->wr_mtx, K_FOREVER);
if (!flag_cmd_ctx_get(shell)) {
@@ -474,7 +474,7 @@ void shell_internal_fprintf(const struct shell *shell,
__ASSERT_NO_MSG(shell->fprintf_ctx);
__ASSERT_NO_MSG(fmt);

va_list args = { 0 };
va_list args;

va_start(args, fmt);
shell_internal_vfprintf(shell, color, fmt, args);

0 comments on commit 71260d8

Please sign in to comment.
You can’t perform that action at this time.