[A] Added more warnings to compilation

This commit is contained in:
seleznevae 2018-11-17 10:44:35 +03:00
parent fe6dbfce4a
commit 88a5d76454
5 changed files with 69 additions and 63 deletions

View File

@ -52,8 +52,19 @@ 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 -Werror -std=c99 -Wpedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -Wextra -Werror -std=c++11")
set(ADDITIONAL_WARNINGS "\
-Wduplicated-cond \
-Wlogical-op \
-Wdouble-promotion \
-Wshadow \
-Wformat=2 \
-Wno-variadic-macros \
-Wcast-align \
")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -Wextra -Werror -std=c99 -Wpedantic ${ADDITIONAL_WARNINGS}")
set(ADDITIONAL_WARNINGS "${ADDITIONAL_WARNINGS} -Wuseless-cast ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -Wextra -Werror -std=c++11 ${ADDITIONAL_WARNINGS}")
endif("${FORT_COMPILER}" STREQUAL "MSVC")

View File

@ -1272,22 +1272,17 @@ static fort_status_t set_cell_property_impl(fort_cell_props_t *opt, uint32_t pro
} else if (PROP_IS_SET(property, FT_CPROP_CELL_BG_COLOR)) {
opt->cell_bg_color_number = value;
} else if (PROP_IS_SET(property, FT_CPROP_CELL_TEXT_STYLE)) {
// opt->cell_text_style = value;
enum ft_text_style v = (enum ft_text_style)value;
if (v == FT_TSTYLE_DEFAULT) {
opt->cell_text_style = FT_TSTYLE_DEFAULT;
} else {
// opt->cell_text_style &= ~((unsigned)FT_TSTYLE_DEFAULT);
opt->cell_text_style |= v;
}
} else if (PROP_IS_SET(property, FT_CPROP_CONT_TEXT_STYLE)) {
// opt->content_text_style = value;
enum ft_text_style v = (enum ft_text_style)value;
if (v == FT_TSTYLE_DEFAULT) {
opt->content_text_style = v;
} else {
// opt->cell_text_style &= ~((unsigned)FT_TSTYLE_DEFAULT);
opt->content_text_style |= v;
}
}
@ -2990,20 +2985,20 @@ struct ft_border_style *FT_FRAME_STYLE = (struct ft_border_style *) &FORT_FRAME
static void set_border_props_for_props(fort_table_properties_t *properties, const struct ft_border_style *style)
{
if ((struct fort_border_style *)style == &FORT_BASIC_STYLE
|| (struct fort_border_style *)style == &FORT_BASIC2_STYLE
|| (struct fort_border_style *)style == &FORT_SIMPLE_STYLE
|| (struct fort_border_style *)style == &FORT_DOT_STYLE
|| (struct fort_border_style *)style == &FORT_PLAIN_STYLE
|| (struct fort_border_style *)style == &FORT_EMPTY_STYLE
|| (struct fort_border_style *)style == &FORT_SOLID_STYLE
|| (struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE
|| (struct fort_border_style *)style == &FORT_NICE_STYLE
|| (struct fort_border_style *)style == &FORT_DOUBLE_STYLE
|| (struct fort_border_style *)style == &FORT_DOUBLE2_STYLE
|| (struct fort_border_style *)style == &FORT_BOLD_STYLE
|| (struct fort_border_style *)style == &FORT_BOLD2_STYLE
|| (struct fort_border_style *)style == &FORT_FRAME_STYLE) {
if ((const struct fort_border_style *)style == &FORT_BASIC_STYLE
|| (const struct fort_border_style *)style == &FORT_BASIC2_STYLE
|| (const struct fort_border_style *)style == &FORT_SIMPLE_STYLE
|| (const struct fort_border_style *)style == &FORT_DOT_STYLE
|| (const struct fort_border_style *)style == &FORT_PLAIN_STYLE
|| (const struct fort_border_style *)style == &FORT_EMPTY_STYLE
|| (const struct fort_border_style *)style == &FORT_SOLID_STYLE
|| (const struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE
|| (const struct fort_border_style *)style == &FORT_NICE_STYLE
|| (const struct fort_border_style *)style == &FORT_DOUBLE_STYLE
|| (const struct fort_border_style *)style == &FORT_DOUBLE2_STYLE
|| (const struct fort_border_style *)style == &FORT_BOLD_STYLE
|| (const struct fort_border_style *)style == &FORT_BOLD2_STYLE
|| (const struct fort_border_style *)style == &FORT_FRAME_STYLE) {
memcpy(&(properties->border_style), (struct fort_border_style *)style, sizeof(struct fort_border_style));
return;
}
@ -4239,13 +4234,13 @@ int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str)
else {
wchar_t wcs[WCS_SIZE];
const char *ptr = str;
size_t length;
length = mbsrtowcs(wcs, (const char **)&ptr, WCS_SIZE, NULL);
size_t wcs_len;
wcs_len = mbsrtowcs(wcs, (const char **)&ptr, WCS_SIZE, NULL);
/* for simplicity */
if ((length == (size_t) - 1) || length > 1) {
if ((wcs_len == (size_t) - 1) || wcs_len > 1) {
return -1;
} else {
wcs[length] = L'\0';
wcs[wcs_len] = L'\0';
size_t k = n;
while (k) {
*buf = *wcs;

View File

@ -693,27 +693,27 @@ int ft_set_border_style(ft_table_t *table, const struct ft_border_style *style);
/**
* @name Colors.
* @{
* Colors.
*/
#define FT_COLOR_DEFAULT 0
#define FT_COLOR_BLACK 1
#define FT_COLOR_RED 2
#define FT_COLOR_GREEN 3
#define FT_COLOR_YELLOW 4
#define FT_COLOR_BLUE 5
#define FT_COLOR_MAGENTA 6
#define FT_COLOR_CYAN 7
#define FT_COLOR_LIGHT_GRAY 8
#define FT_COLOR_DARK_GRAY 9
#define FT_COLOR_LIGHT_RED 10
#define FT_COLOR_LIGHT_GREEN 11
#define FT_COLOR_LIGHT_YELLOW 12
#define FT_COLOR_LIGHT_BLUE 13
#define FT_COLOR_LIGHT_MAGENTA 15
#define FT_COLOR_LIGHT_CYAN 16
#define FT_COLOR_LIGHT_WHYTE 17
/** @} */
enum ft_color {
FT_COLOR_DEFAULT = 0,
FT_COLOR_BLACK = 1,
FT_COLOR_RED = 2,
FT_COLOR_GREEN = 3,
FT_COLOR_YELLOW = 4,
FT_COLOR_BLUE = 5,
FT_COLOR_MAGENTA = 6,
FT_COLOR_CYAN = 7,
FT_COLOR_LIGHT_GRAY = 8,
FT_COLOR_DARK_GRAY = 9,
FT_COLOR_LIGHT_RED = 10,
FT_COLOR_LIGHT_GREEN = 11,
FT_COLOR_LIGHT_YELLOW = 12,
FT_COLOR_LIGHT_BLUE = 13,
FT_COLOR_LIGHT_MAGENTA = 15,
FT_COLOR_LIGHT_CYAN = 16,
FT_COLOR_LIGHT_WHYTE = 17
};
/**
* Text styles.

View File

@ -847,20 +847,20 @@ struct ft_border_style *FT_FRAME_STYLE = (struct ft_border_style *) &FORT_FRAME
static void set_border_props_for_props(fort_table_properties_t *properties, const struct ft_border_style *style)
{
if ((struct fort_border_style *)style == &FORT_BASIC_STYLE
|| (struct fort_border_style *)style == &FORT_BASIC2_STYLE
|| (struct fort_border_style *)style == &FORT_SIMPLE_STYLE
|| (struct fort_border_style *)style == &FORT_DOT_STYLE
|| (struct fort_border_style *)style == &FORT_PLAIN_STYLE
|| (struct fort_border_style *)style == &FORT_EMPTY_STYLE
|| (struct fort_border_style *)style == &FORT_SOLID_STYLE
|| (struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE
|| (struct fort_border_style *)style == &FORT_NICE_STYLE
|| (struct fort_border_style *)style == &FORT_DOUBLE_STYLE
|| (struct fort_border_style *)style == &FORT_DOUBLE2_STYLE
|| (struct fort_border_style *)style == &FORT_BOLD_STYLE
|| (struct fort_border_style *)style == &FORT_BOLD2_STYLE
|| (struct fort_border_style *)style == &FORT_FRAME_STYLE) {
if ((const struct fort_border_style *)style == &FORT_BASIC_STYLE
|| (const struct fort_border_style *)style == &FORT_BASIC2_STYLE
|| (const struct fort_border_style *)style == &FORT_SIMPLE_STYLE
|| (const struct fort_border_style *)style == &FORT_DOT_STYLE
|| (const struct fort_border_style *)style == &FORT_PLAIN_STYLE
|| (const struct fort_border_style *)style == &FORT_EMPTY_STYLE
|| (const struct fort_border_style *)style == &FORT_SOLID_STYLE
|| (const struct fort_border_style *)style == &FORT_SOLID_ROUND_STYLE
|| (const struct fort_border_style *)style == &FORT_NICE_STYLE
|| (const struct fort_border_style *)style == &FORT_DOUBLE_STYLE
|| (const struct fort_border_style *)style == &FORT_DOUBLE2_STYLE
|| (const struct fort_border_style *)style == &FORT_BOLD_STYLE
|| (const struct fort_border_style *)style == &FORT_BOLD2_STYLE
|| (const struct fort_border_style *)style == &FORT_FRAME_STYLE) {
memcpy(&(properties->border_style), (struct fort_border_style *)style, sizeof(struct fort_border_style));
return;
}

View File

@ -260,13 +260,13 @@ int wsnprint_n_string(wchar_t *buf, size_t length, size_t n, const char *str)
else {
wchar_t wcs[WCS_SIZE];
const char *ptr = str;
size_t length;
length = mbsrtowcs(wcs, (const char **)&ptr, WCS_SIZE, NULL);
size_t wcs_len;
wcs_len = mbsrtowcs(wcs, (const char **)&ptr, WCS_SIZE, NULL);
/* for simplicity */
if ((length == (size_t) - 1) || length > 1) {
if ((wcs_len == (size_t) - 1) || wcs_len > 1) {
return -1;
} else {
wcs[length] = L'\0';
wcs[wcs_len] = L'\0';
size_t k = n;
while (k) {
*buf = *wcs;