fix warings

This commit is contained in:
Gabor Kiss-Vamosi
2020-05-24 13:13:07 +02:00
parent 1c9830b715
commit a2c973bd5b
24 changed files with 147 additions and 103 deletions

View File

@@ -5,13 +5,11 @@ CC ?= gcc
LVGL_DIR ?= ${shell pwd}/../..
LVGL_DIR_NAME ?= lvgl
WARNINGS ?= -Werror -Wall -Wextra \
-Wshadow -Wundef -Wmaybe-uninitialized -Wmissing-prototypes -Wno-discarded-qualifiers \
-Wno-unused-function -Wno-error=strict-prototypes -Wpointer-arith -fno-strict-aliasing -Wno-error=cpp -Wuninitialized \
-Wno-unused-parameter -Wno-missing-field-initializers -Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default \
-Wreturn-type -Wmultichar -Wformat-security -Wno-ignored-qualifiers -Wno-error=pedantic -Wno-sign-compare -Wno-error=missing-prototypes -Wdouble-promotion -Wclobbered -Wdeprecated \
WARNINGS = -Werror -Wall -Wextra \
-Wshadow -Wundef -Wmaybe-uninitialized -Wmissing-prototypes -Wpointer-arith -Wuninitialized \
-Wunreachable-code -Wreturn-type -Wmultichar -Wformat-security -Wdouble-promotion -Wclobbered -Wdeprecated \
-Wempty-body -Wshift-negative-value -Wstack-usage=2048 \
-Wtype-limits -Wsizeof-pointer-memaccess -Wpointer-arith
-Wtype-limits -Wsizeof-pointer-memaccess
#-Wno-unused-value -Wno-unused-parameter
OPTIMIZATION ?= -O3 -g0

View File

@@ -11,7 +11,7 @@ optimization = '"-O3 -g0"'
def build(name, defines):
global warnings, base_defines, optimization
global base_defines, optimization
print("=============================")
print(name)

View File

@@ -48,9 +48,9 @@ typedef struct {
* STATIC PROTOTYPES
**********************/
static void read_png_file(png_img_t * p, const char* file_name);
static void write_png_file(png_img_t * p, const char* file_name);
//static void write_png_file(png_img_t * p, const char* file_name);
static void png_release(png_img_t * p);
static void process_file(png_img_t * p);
//static void process_file(png_img_t * p);
/**********************
* STATIC VARIABLES
@@ -254,59 +254,59 @@ static void read_png_file(png_img_t * p, const char* file_name)
fclose(fp);
}
static void write_png_file(png_img_t * p, const char* file_name)
{
/* create file */
FILE *fp = fopen(file_name, "wb");
if (!fp)
lv_test_exit("[write_png_file] File %s could not be opened for writing", file_name);
/* initialize stuff */
p->png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!p->png_ptr)
lv_test_exit("[write_png_file] png_create_write_struct failed");
p->info_ptr = png_create_info_struct(p->png_ptr);
if (!p->info_ptr)
lv_test_exit("[write_png_file] png_create_info_struct failed");
if (setjmp(png_jmpbuf(p->png_ptr)))
lv_test_exit("[write_png_file] Error during init_io");
png_init_io(p->png_ptr, fp);
/* write header */
if (setjmp(png_jmpbuf(p->png_ptr)))
lv_test_exit("[write_png_file] Error during writing header");
png_set_IHDR(p->png_ptr, p->info_ptr, p->width, p->height,
p->bit_depth, p->color_type, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_write_info(p->png_ptr, p->info_ptr);
/* write bytes */
if (setjmp(png_jmpbuf(p->png_ptr)))
lv_test_exit("[write_png_file] Error during writing bytes");
png_write_image(p->png_ptr, p->row_pointers);
/* end write */
if (setjmp(png_jmpbuf(p->png_ptr)))
lv_test_exit("[write_png_file] Error during end of write");
png_write_end(p->png_ptr, NULL);
fclose(fp);
}
//
//
//static void write_png_file(png_img_t * p, const char* file_name)
//{
// /* create file */
// FILE *fp = fopen(file_name, "wb");
// if (!fp)
// lv_test_exit("[write_png_file] File %s could not be opened for writing", file_name);
//
//
// /* initialize stuff */
// p->png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
//
// if (!p->png_ptr)
// lv_test_exit("[write_png_file] png_create_write_struct failed");
//
// p->info_ptr = png_create_info_struct(p->png_ptr);
// if (!p->info_ptr)
// lv_test_exit("[write_png_file] png_create_info_struct failed");
//
// if (setjmp(png_jmpbuf(p->png_ptr)))
// lv_test_exit("[write_png_file] Error during init_io");
//
// png_init_io(p->png_ptr, fp);
//
//
// /* write header */
// if (setjmp(png_jmpbuf(p->png_ptr)))
// lv_test_exit("[write_png_file] Error during writing header");
//
// png_set_IHDR(p->png_ptr, p->info_ptr, p->width, p->height,
// p->bit_depth, p->color_type, PNG_INTERLACE_NONE,
// PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
//
// png_write_info(p->png_ptr, p->info_ptr);
//
//
// /* write bytes */
// if (setjmp(png_jmpbuf(p->png_ptr)))
// lv_test_exit("[write_png_file] Error during writing bytes");
//
// png_write_image(p->png_ptr, p->row_pointers);
//
//
// /* end write */
// if (setjmp(png_jmpbuf(p->png_ptr)))
// lv_test_exit("[write_png_file] Error during end of write");
//
// png_write_end(p->png_ptr, NULL);
//
// fclose(fp);
//}
//
static void png_release(png_img_t * p)
{
int y;
@@ -314,30 +314,30 @@ static void png_release(png_img_t * p)
free(p->row_pointers[y]);
free(p->row_pointers);
}
static void process_file(png_img_t * p)
{
if (png_get_color_type(p->png_ptr, p->info_ptr) == PNG_COLOR_TYPE_RGB)
lv_test_exit("[process_file] input file is PNG_COLOR_TYPE_RGB but must be PNG_COLOR_TYPE_RGBA "
"(lacks the alpha channel)");
if (png_get_color_type(p->png_ptr, p->info_ptr) != PNG_COLOR_TYPE_RGBA)
lv_test_exit("[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (%d) (is %d)",
PNG_COLOR_TYPE_RGBA, png_get_color_type(p->png_ptr, p->info_ptr));
int x, y;
for (y=0; y<p->height; y++) {
png_byte* row = p->row_pointers[y];
for (x=0; x<p->width; x++) {
png_byte* ptr = &(row[x*4]);
printf("Pixel at position [ %d - %d ] has RGBA values: %d - %d - %d - %d\n",
x, y, ptr[0], ptr[1], ptr[2], ptr[3]);
/* set red value to 0 and green value to the blue one */
ptr[0] = 0;
ptr[1] = ptr[2];
}
}
}
//
//static void process_file(png_img_t * p)
//{
// if (png_get_color_type(p->png_ptr, p->info_ptr) == PNG_COLOR_TYPE_RGB)
// lv_test_exit("[process_file] input file is PNG_COLOR_TYPE_RGB but must be PNG_COLOR_TYPE_RGBA "
// "(lacks the alpha channel)");
//
// if (png_get_color_type(p->png_ptr, p->info_ptr) != PNG_COLOR_TYPE_RGBA)
// lv_test_exit("[process_file] color_type of input file must be PNG_COLOR_TYPE_RGBA (%d) (is %d)",
// PNG_COLOR_TYPE_RGBA, png_get_color_type(p->png_ptr, p->info_ptr));
//
// int x, y;
// for (y=0; y<p->height; y++) {
// png_byte* row = p->row_pointers[y];
// for (x=0; x<p->width; x++) {
// png_byte* ptr = &(row[x*4]);
// printf("Pixel at position [ %d - %d ] has RGBA values: %d - %d - %d - %d\n",
// x, y, ptr[0], ptr[1], ptr[2], ptr[3]);
//
// /* set red value to 0 and green value to the blue one */
// ptr[0] = 0;
// ptr[1] = ptr[2];
// }
// }
//}
#endif

View File

@@ -40,6 +40,8 @@ static void hal_init(void)
static void dummy_flush_cb(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
LV_UNUSED(area);
LV_UNUSED(color_p);
lv_disp_flush_ready(disp_drv);
}