From e8f6bee7f5c773a40cdf17689dd07e9446ce0278 Mon Sep 17 00:00:00 2001 From: seleznevae Date: Tue, 8 May 2018 21:46:24 +0300 Subject: [PATCH] [F] Fixed warnings with -Wpedantic option --- CMakeLists.txt | 2 +- lib/fort.c | 24 +++--------------------- src/fort_utils.h | 6 +++--- src/options.h | 7 ------- src/row.h | 4 ---- src/string_buffer.h | 2 -- src/table.h | 2 -- src/vector.h | 3 --- tests/bb_tests/test_memory_errors.c | 8 +++++--- tests/test_utils.c | 2 -- tests/tests.h | 4 ++-- 11 files changed, 14 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15463dc..993a37a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ if("${FORT_COMPILER}" STREQUAL "MSVC") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W4") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W4") else("${FORT_COMPILER}" STREQUAL "MSVC") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Wextra") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Wextra -std=c99 -Wpedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -Wextra") endif("${FORT_COMPILER}" STREQUAL "MSVC") diff --git a/lib/fort.c b/lib/fort.c index 2bdf446..de3aef7 100644 --- a/lib/fort.c +++ b/lib/fort.c @@ -129,7 +129,7 @@ typedef struct vector vector_t; typedef struct fort_cell fort_cell_t; typedef struct string_buffer string_buffer_t; typedef struct fort_row fort_row_t; -typedef struct ft_table ft_table_t; +/*typedef struct ft_table ft_table_t;*/ typedef struct separator separator_t; @@ -157,8 +157,8 @@ char *fort_strdup(const char *str); wchar_t *fort_wcsdup(const wchar_t *str); size_t number_of_columns_in_format_string(const char *fmt); size_t number_of_columns_in_format_wstring(const wchar_t *fmt); -//int snprint_n_chars(char *buf, size_t length, size_t n, char ch); -//int wsnprint_n_chars(wchar_t *buf, size_t length, size_t n, wchar_t ch); +/*int snprint_n_chars(char *buf, size_t length, size_t n, char ch);*/ +/*int wsnprint_n_chars(wchar_t *buf, size_t length, size_t n, wchar_t ch);*/ int snprint_n_strings(char *buf, size_t length, size_t n, const char *str); int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str); @@ -197,9 +197,6 @@ int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str); * VECTOR * ***************************************************************************/ -struct vector; -typedef struct vector vector_t; - #define INVALID_VEC_INDEX ((size_t) -1) extern vector_t *create_vector(size_t item_size, size_t capacity); @@ -267,8 +264,6 @@ enum str_buf_type { WCharBuf }; -struct string_buffer; -typedef struct string_buffer string_buffer_t; struct string_buffer { union { char *cstr; @@ -318,16 +313,10 @@ struct fort_column_options { int col_min_width; enum ft_text_alignment align; }; -typedef struct fort_column_options fort_column_options_t; extern fort_column_options_t g_column_options; fort_column_options_t create_column_options(void); - - -struct vector; -typedef struct vector vector_t; - #define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option)) #define OPTION_SET(ft_opts, option) ((ft_opts) |=(option)) #define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option)) @@ -450,7 +439,6 @@ struct fort_table_options { fort_cell_opt_container_t *cell_options; fort_entire_table_options_t entire_table_options; }; -typedef struct fort_table_options fort_table_options_t; extern fort_table_options_t g_table_options; size_t max_border_elem_strlen(struct fort_table_options *); @@ -533,10 +521,6 @@ string_buffer_t *cell_get_string_buffer(fort_cell_t *cell); #include #endif -struct fort_row; -typedef struct fort_row fort_row_t; - - fort_row_t *create_row(void); void destroy_row(fort_row_t *row); fort_row_t *create_row_from_string(const char *str); @@ -600,8 +584,6 @@ int wsnprintf_row(const fort_row_t *row, wchar_t *buffer, size_t buf_sz, size_t /* #include "fort_utils.h" */ /* Commented by amalgamation script */ -struct ft_table; -typedef struct ft_table ft_table_t; struct ft_table { vector_t *rows; fort_table_options_t *options; diff --git a/src/fort_utils.h b/src/fort_utils.h index eaaebcf..9297b8f 100644 --- a/src/fort_utils.h +++ b/src/fort_utils.h @@ -94,7 +94,7 @@ typedef struct vector vector_t; typedef struct fort_cell fort_cell_t; typedef struct string_buffer string_buffer_t; typedef struct fort_row fort_row_t; -typedef struct ft_table ft_table_t; +/*typedef struct ft_table ft_table_t;*/ typedef struct separator separator_t; @@ -122,8 +122,8 @@ char *fort_strdup(const char *str); wchar_t *fort_wcsdup(const wchar_t *str); size_t number_of_columns_in_format_string(const char *fmt); size_t number_of_columns_in_format_wstring(const wchar_t *fmt); -//int snprint_n_chars(char *buf, size_t length, size_t n, char ch); -//int wsnprint_n_chars(wchar_t *buf, size_t length, size_t n, wchar_t ch); +/*int snprint_n_chars(char *buf, size_t length, size_t n, char ch);*/ +/*int wsnprint_n_chars(wchar_t *buf, size_t length, size_t n, wchar_t ch);*/ int snprint_n_strings(char *buf, size_t length, size_t n, const char *str); int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str); diff --git a/src/options.h b/src/options.h index 6e2eea7..8a1469d 100644 --- a/src/options.h +++ b/src/options.h @@ -9,16 +9,10 @@ struct fort_column_options { int col_min_width; enum ft_text_alignment align; }; -typedef struct fort_column_options fort_column_options_t; extern fort_column_options_t g_column_options; fort_column_options_t create_column_options(void); - - -struct vector; -typedef struct vector vector_t; - #define OPTION_IS_SET(ft_opts, option) ((ft_opts) & (option)) #define OPTION_SET(ft_opts, option) ((ft_opts) |=(option)) #define OPTION_UNSET(ft_opts, option) ((ft_opts) &= ~((uint32_t)option)) @@ -141,7 +135,6 @@ struct fort_table_options { fort_cell_opt_container_t *cell_options; fort_entire_table_options_t entire_table_options; }; -typedef struct fort_table_options fort_table_options_t; extern fort_table_options_t g_table_options; size_t max_border_elem_strlen(struct fort_table_options *); diff --git a/src/row.h b/src/row.h index 1af2a9f..7b5e489 100644 --- a/src/row.h +++ b/src/row.h @@ -9,10 +9,6 @@ #include #endif -struct fort_row; -typedef struct fort_row fort_row_t; - - fort_row_t *create_row(void); void destroy_row(fort_row_t *row); fort_row_t *create_row_from_string(const char *str); diff --git a/src/string_buffer.h b/src/string_buffer.h index 41b1b89..a661ad5 100644 --- a/src/string_buffer.h +++ b/src/string_buffer.h @@ -12,8 +12,6 @@ enum str_buf_type { WCharBuf }; -struct string_buffer; -typedef struct string_buffer string_buffer_t; struct string_buffer { union { char *cstr; diff --git a/src/table.h b/src/table.h index 77e6f5d..52d9e4e 100644 --- a/src/table.h +++ b/src/table.h @@ -3,8 +3,6 @@ #include "fort_utils.h" -struct ft_table; -typedef struct ft_table ft_table_t; struct ft_table { vector_t *rows; fort_table_options_t *options; diff --git a/src/vector.h b/src/vector.h index 4f9a952..ea20dc9 100644 --- a/src/vector.h +++ b/src/vector.h @@ -8,9 +8,6 @@ * VECTOR * ***************************************************************************/ -struct vector; -typedef struct vector vector_t; - #define INVALID_VEC_INDEX ((size_t) -1) extern vector_t *create_vector(size_t item_size, size_t capacity); diff --git a/tests/bb_tests/test_memory_errors.c b/tests/bb_tests/test_memory_errors.c index 2bb9613..b7a9089 100644 --- a/tests/bb_tests/test_memory_errors.c +++ b/tests/bb_tests/test_memory_errors.c @@ -34,8 +34,10 @@ static int create_simple_table_and_show(void) result = 1; goto exit; } -// if (set_test_options_for_table(table) != FT_SUCCESS) -// return 2; + /* + if (set_test_options_for_table(table) != FT_SUCCESS) + return 2; + */ if (ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER) != FT_SUCCESS) { result = 3; @@ -73,7 +75,7 @@ static int create_simple_table_and_show(void) "| 3 | c | 234 | 3.140000 |\n" "| | | | |\n" "+---+---+-----+----------+\n"; -// assert_str_equal(table_str, table_str_etalon); + /*assert_str_equal(table_str, table_str_etalon);*/ if (strcmp(table_str, table_str_etalon) != 0) { result = 8; goto exit; diff --git a/tests/test_utils.c b/tests/test_utils.c index 99010e0..dddf101 100644 --- a/tests/test_utils.c +++ b/tests/test_utils.c @@ -84,7 +84,6 @@ struct ft_table *create_test_int_table(int set_test_opts) assert_true(table != NULL); ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); -// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67); int n = ft_write_ln(table, "3", "4", "55", "67"); assert(n == FT_SUCCESS); @@ -115,7 +114,6 @@ struct ft_table *create_test_int_wtable(int set_test_opts) assert_true(table != NULL); ft_set_cell_option(table, 0, FT_ANY_COLUMN, FT_COPT_ROW_TYPE, FT_ROW_HEADER); -// int n = ft_printf_ln(table, "%d|%d|%d|%d", 3, 4, 55, 67); int n = ft_wwrite_ln(table, L"3", L"4", L"55", L"67"); assert(n == FT_SUCCESS); diff --git a/tests/tests.h b/tests/tests.h index 2f990a7..9cd7d55 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -49,7 +49,7 @@ struct test_case { #define assert_str_equal(str1, str2) \ if (strcmp(str1, str2) != 0) \ { \ - fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __FUNCTION__); \ + fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __func__); \ fprintf(stderr, "Left string:\n%s\n", str1); \ fprintf(stderr, "Right string:\n%s\n", str2); \ exit(EXIT_FAILURE); \ @@ -58,7 +58,7 @@ struct test_case { #define assert_wcs_equal(str1, str2) \ if (wcscmp(str1, str2) != 0) \ { \ - fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __FUNCTION__); \ + fprintf(stderr, "%s:%d(%s):Abort! Not equals strings:\n",__FILE__,__LINE__, __func__); \ setlocale(LC_CTYPE, ""); \ fwprintf(stdout, L"Left string:\n%ls\n", str1); \ fwprintf(stdout, L"Right string:\n%ls\n", str2); \