From 0cd5fbfd816e48d4be4077317a5b68a76e580715 Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Thu, 14 Aug 2014 17:55:46 +0400 Subject: [PATCH] Adding src/main.c to cppcheck and vera++ source list. --- Makefile.mk | 4 +- src/main.c | 156 ++++++++++++++++++++++++++-------------------------- 2 files changed, 80 insertions(+), 80 deletions(-) diff --git a/Makefile.mk b/Makefile.mk index 1e4d397bc..1987801e4 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -365,9 +365,9 @@ all: clean $(JERRY_TARGETS) $(JERRY_TARGETS): @rm -rf $(TARGET_DIR) @mkdir -p $(TARGET_DIR) - @cppcheck $(DEFINES_JERRY) $(SOURCES_JERRY_C) $(INCLUDES_JERRY) $(INCLUDES_THIRDPARTY) \ + @cppcheck $(DEFINES_JERRY) $(SOURCES_JERRY_C) $(MAIN_MODULE_SRC) $(INCLUDES_JERRY) $(INCLUDES_THIRDPARTY) \ --error-exitcode=1 --std=c99 --enable=all --suppress=missingIncludeSystem --suppress=unusedFunction 1>/dev/null - @vera++ -r ./tools/vera++ -p jerry $(SOURCES_JERRY_C) $(SOURCES_JERRY_H) -e --no-duplicate 1>$(TARGET_DIR)/vera.log + @vera++ -r ./tools/vera++ -p jerry $(SOURCES_JERRY_C) $(MAIN_MODULE_SRC) $(SOURCES_JERRY_H) -e --no-duplicate 1>$(TARGET_DIR)/vera.log @mkdir -p $(TARGET_DIR)/obj @source_index=0; \ for jerry_src in $(SOURCES_JERRY) $(MAIN_MODULE_SRC); do \ diff --git a/src/main.c b/src/main.c index 7e9b3ef21..ec7ede836 100644 --- a/src/main.c +++ b/src/main.c @@ -41,7 +41,7 @@ parser_run (const char *script_source, size_t script_source_size, bool is_show_o uint16_t offset; const OPCODE *opcodes; - lexer_init ( script_source, script_source_size, is_show_opcodes); + lexer_init (script_source, script_source_size, is_show_opcodes); lexer_run_first_pass (); @@ -51,7 +51,7 @@ parser_run (const char *script_source, size_t script_source_size, bool is_show_o offset = serializer_dump_strings (strings, strings_num); serializer_dump_nums (nums, nums_count, offset, strings_num); - + parser_init (); parser_parse_program (); @@ -74,24 +74,24 @@ jerry_run (const char *script_source, size_t script_source_size, { const OPCODE *opcodes; - mem_init(); + mem_init (); serializer_init (is_show_opcodes); opcodes = parser_run (script_source, script_source_size, is_show_opcodes); if (is_parse_only) - { - return true; - } + { + return true; + } init_int (opcodes); - + bool is_success = run_int (); - serializer_free(); + serializer_free (); - mem_finalize( is_show_mem_stats); + mem_finalize (is_show_mem_stats); return is_success; } /* jerry_run */ @@ -108,52 +108,52 @@ read_sources (const char *script_file_names[], uint8_t *source_buffer_tail = source_buffer; for (i = 0; i < files_count; i++) + { + const char *script_file_name = script_file_names[i]; + + _FILE *file = __fopen (script_file_name, "r"); + + if (file == NULL) { - const char *script_file_name = script_file_names[i]; - - _FILE *file = __fopen (script_file_name, "r"); - - if (file == NULL) - { - jerry_exit (ERR_IO); - } - - int fseek_status = __fseek( file, 0, __SEEK_END); - - if ( fseek_status != 0 ) - { - jerry_exit (ERR_IO); - } - - long script_len = __ftell( file); - - if ( script_len < 0 ) - { - jerry_exit (ERR_IO); - } - - __rewind( file); - - const size_t current_source_size = (size_t)script_len; - - if ( source_buffer_tail + current_source_size >= source_buffer + sizeof(source_buffer) ) - { - jerry_exit (ERR_MEMORY); - } - - size_t bytes_read = __fread( source_buffer, 1, current_source_size, file); - if ( bytes_read < current_source_size ) - { - jerry_exit (ERR_IO); - } - - __fclose( file); - - source_buffer_tail += current_source_size; + jerry_exit (ERR_IO); } + int fseek_status = __fseek (file, 0, __SEEK_END); + + if (fseek_status != 0) + { + jerry_exit (ERR_IO); + } + + long script_len = __ftell (file); + + if (script_len < 0) + { + jerry_exit (ERR_IO); + } + + __rewind (file); + + const size_t current_source_size = (size_t)script_len; + + if (source_buffer_tail + current_source_size >= source_buffer + sizeof (source_buffer)) + { + jerry_exit (ERR_MEMORY); + } + + size_t bytes_read = __fread (source_buffer, 1, current_source_size, file); + if (bytes_read < current_source_size) + { + jerry_exit (ERR_IO); + } + + __fclose (file); + + source_buffer_tail += current_source_size; + } + const size_t source_size = (size_t) (source_buffer_tail - source_buffer); - JERRY_ASSERT( source_size < sizeof(source_buffer)); + JERRY_ASSERT(source_size < sizeof (source_buffer)); *out_source_size_p = source_size; @@ -174,37 +174,37 @@ main (int argc __unused, CONFIG_MEM_STACK_LIMIT); for (i = 1; i < argc; i++) + { + if (!__strcmp ("-v", argv[i])) { - if (!__strcmp ("-v", argv[i])) - { - __printf ("Build date: \t%s\n", JERRY_BUILD_DATE); - __printf ("Commit hash:\t%s\n", JERRY_COMMIT_HASH); - __printf ("Branch name:\t%s\n", JERRY_BRANCH_NAME); - __printf ("\n"); - } - if (!__strcmp ("--mem-stats", argv[i])) - { - print_mem_stats = true; - } - else if (!__strcmp ("--parse-only", argv[i])) - { - parse_only = true; - } - else if (!__strcmp ("--show-opcodes", argv[i])) - { - show_opcodes = true; - } - else - { - file_names[files_counter++] = argv[i]; - } + __printf ("Build date: \t%s\n", JERRY_BUILD_DATE); + __printf ("Commit hash:\t%s\n", JERRY_COMMIT_HASH); + __printf ("Branch name:\t%s\n", JERRY_BRANCH_NAME); + __printf ("\n"); } + if (!__strcmp ("--mem-stats", argv[i])) + { + print_mem_stats = true; + } + else if (!__strcmp ("--parse-only", argv[i])) + { + parse_only = true; + } + else if (!__strcmp ("--show-opcodes", argv[i])) + { + show_opcodes = true; + } + else + { + file_names[files_counter++] = argv[i]; + } + } if (files_counter == 0) - { - jerry_exit (ERR_NO_FILES); - } - + { + jerry_exit (ERR_NO_FILES); + } + size_t source_size; const char *source_p = read_sources (file_names, files_counter, &source_size);