From 06910b456e80d9f856630fca3a7d79036a640c6e Mon Sep 17 00:00:00 2001 From: Akos Kiss Date: Thu, 24 May 2018 08:48:34 +0200 Subject: [PATCH] Fix issues revealed by cppcheck 1.83 (#2355) A more recent cppcheck has revealed some extra issues not detected by the old one running on CI. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu --- jerry-core/api/jerry-snapshot.c | 10 ++++------ jerry-main/cli.c | 2 +- jerry-main/main-unix.c | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/jerry-core/api/jerry-snapshot.c b/jerry-core/api/jerry-snapshot.c index 935f6951c..5639fd248 100644 --- a/jerry-core/api/jerry-snapshot.c +++ b/jerry-core/api/jerry-snapshot.c @@ -1488,15 +1488,13 @@ jerry_append_ecma_string_to_buffer (uint8_t *buffer_p, /**< buffer */ uint8_t *buffer_end_p, /**< the end of the buffer */ ecma_string_t *string_p) /**< ecma-string */ { - uint8_t *new_buffer_p = NULL; - ECMA_STRING_TO_UTF8_STRING (string_p, str_buffer_p, str_buffer_size); /* Append the string to the buffer. */ - new_buffer_p = jerry_append_chars_to_buffer (buffer_p, - buffer_end_p, - (const char *) str_buffer_p, - str_buffer_size); + uint8_t *new_buffer_p = jerry_append_chars_to_buffer (buffer_p, + buffer_end_p, + (const char *) str_buffer_p, + str_buffer_size); ECMA_FINALIZE_UTF8_STRING (str_buffer_p, str_buffer_size); diff --git a/jerry-main/cli.c b/jerry-main/cli.c index 77a7c755c..1f8c878f7 100644 --- a/jerry-main/cli.c +++ b/jerry-main/cli.c @@ -362,7 +362,7 @@ cli_print_help (const char *help) /**< the help message to print */ cli_print_prefix (help, length); help += length; - while (*help == ' ' && *help != 0) + while (*help == ' ') { help++; } diff --git a/jerry-main/main-unix.c b/jerry-main/main-unix.c index d7dd3925a..61d666c2d 100644 --- a/jerry-main/main-unix.c +++ b/jerry-main/main-unix.c @@ -121,7 +121,7 @@ print_unhandled_exception (jerry_value_t error_value) /**< error value */ if (str_size >= 256) { - printf ("%3d: [Backtrace string too long]\n", i); + printf ("%3u: [Backtrace string too long]\n", i); } else { @@ -129,7 +129,7 @@ print_unhandled_exception (jerry_value_t error_value) /**< error value */ assert (string_end == str_size); err_str_buf[string_end] = 0; - printf ("%3d: %s\n", i, err_str_buf); + printf ("%3u: %s\n", i, err_str_buf); } }