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>
This commit is contained in:
Jakob Olesen 2019-06-06 11:27:12 -07:00 committed by Carles Cufí
commit 71260d88d5
2 changed files with 2 additions and 2 deletions

View file

@ -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)) {

View file

@ -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);