Skip to content

Commit

Permalink
fix various minor warnings
Browse files Browse the repository at this point in the history
- remove stdio.h when possible
- use LV_LOG_WARN to instead of printf
  • Loading branch information
kisvegabor committed Oct 26, 2021
1 parent 47cdfa6 commit 924bc75
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lv_conf_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
/*Use exnternal renderer*/
#define LV_USE_EXTERNAL_RENDERER 0

/*Use SDL renderer API*/
/*Use SDL renderer API. Requires LV_USE_EXTERNAL_RENDERER*/
#define LV_USE_GPU_SDL 0
#if LV_USE_GPU_SDL
# define LV_GPU_SDL_INCLUDE_PATH <SDL2/SDL.h>
Expand Down
2 changes: 1 addition & 1 deletion src/core/lv_obj_draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef struct {
const lv_point_t *
p1; /**< A point calculated during drawing. E.g. a point of chart or the center of an arc.*/
const lv_point_t * p2; /**< A point calculated during drawing. E.g. a point of chart.*/
const char * text; /**< A text calculated during drawing. Can be modified. E.g. tick labels on a chart axis.*/
char * text; /**< A text calculated during drawing. Can be modified. E.g. tick labels on a chart axis.*/
uint32_t text_length; /**< Size of the text buffer containing null-terminated text string calculated during drawing.*/
uint32_t part; /**< The current part for which the event is sent*/
uint32_t id; /**< The index of the part. E.g. a button's index on button matrix or table cell index.*/
Expand Down
10 changes: 6 additions & 4 deletions src/draw/lv_draw_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ typedef uint8_t cmd_state_t;
LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g,
const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
#endif

#if LV_DRAW_COMPLEX && LV_USE_FONT_SUBPX
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
#endif
#endif /*LV_DRAW_COMPLEX && LV_USE_FONT_SUBPX*/
#endif /*LV_USE_EXTERNAL_RENDERER*/

static uint8_t hex_char_to_num(char hex);

/**********************
Expand Down Expand Up @@ -624,7 +625,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_

lv_mem_buf_release(mask_buf);
}
#endif

#if LV_DRAW_COMPLEX && LV_USE_FONT_SUBPX
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
Expand Down Expand Up @@ -830,8 +830,9 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
lv_mem_buf_release(mask_buf);
lv_mem_buf_release(color_buf);
}
#endif
#endif /*LV_DRAW_COMPLEX && LV_USE_FONT_SUBPX*/

#endif /*LV_USE_EXTERNAL_RENDERER*/
/**
* Convert a hexadecimal characters to a number (0..15)
* @param hex Pointer to a hexadecimal character (0..9, A..F)
Expand Down Expand Up @@ -874,3 +875,4 @@ static uint8_t hex_char_to_num(char hex)

return result;
}

1 change: 0 additions & 1 deletion src/extra/libs/gif/gifdec.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "../../../misc/lv_color.h"
#if LV_USE_GIF

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
Expand Down
1 change: 0 additions & 1 deletion src/extra/libs/png/lodepng.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Rename this file to lodepng.cpp to use it for C++, or to lodepng.c to use it for

#ifdef LODEPNG_COMPILE_DISK
#include <limits.h> /* LONG_MAX */
#include <stdio.h> /* file handling */
#endif /* LODEPNG_COMPILE_DISK */

#ifdef LODEPNG_COMPILE_ALLOCATORS
Expand Down
5 changes: 2 additions & 3 deletions src/extra/libs/png/lv_png.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "lv_png.h"
#include "lodepng.h"
#include <stdlib.h>
#include <stdio.h>

/*********************
* DEFINES
Expand Down Expand Up @@ -136,7 +135,7 @@ static lv_res_t decoder_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t *

error = lodepng_load_file(&png_data, &png_data_size, fn); /*Load the file*/
if(error) {
printf("error %u: %s\n", error, lodepng_error_text(error));
LV_LOG_WARN("error %u: %s\n", error, lodepng_error_text(error));
return LV_RES_INV;
}

Expand All @@ -148,7 +147,7 @@ static lv_res_t decoder_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t *
error = lodepng_decode32(&img_data, &png_width, &png_height, png_data, png_data_size);
lv_mem_free(png_data); /*Free the loaded file*/
if(error) {
printf("error %u: %s\n", error, lodepng_error_text(error));
LV_LOG_WARN("error %u: %s\n", error, lodepng_error_text(error));
return LV_RES_INV;
}

Expand Down
1 change: 0 additions & 1 deletion src/extra/libs/sjpg/lv_sjpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#include "lv_sjpg.h"
#include "../../../misc/lv_fs.h"


/*********************
* DEFINES
*********************/
Expand Down
2 changes: 0 additions & 2 deletions src/extra/libs/sjpg/lv_sjpg.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ extern "C" {
* INCLUDES
*********************/

#include <stdio.h>

#if LV_USE_SJPG

/*********************
Expand Down
4 changes: 4 additions & 0 deletions src/gpu/lv_gpu_sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ extern "C" {

#if LV_USE_GPU_SDL

#if LV_USE_EXTERNAL_RENDERER == 0
#error "SDL GPU requires LV_USE_EXTERNAL_RENDERER 1. Enable it in lv_conf.h"
#endif

#include LV_GPU_SDL_INCLUDE_PATH

/*********************
Expand Down
7 changes: 7 additions & 0 deletions src/gpu/sdl/lv_gpu_sdl_draw_blend.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ void _lv_blend_map(const lv_area_t * clip_area, const lv_area_t * map_area,
const lv_color_t * map_buf, lv_opa_t * mask, lv_draw_mask_res_t mask_res, lv_opa_t opa,
lv_blend_mode_t mode)
{
LV_UNUSED(clip_area);
LV_UNUSED(map_area);
LV_UNUSED(map_buf);
LV_UNUSED(mask);
LV_UNUSED(mask_res);
LV_UNUSED(opa);
LV_UNUSED(mode);

}

Expand Down
16 changes: 8 additions & 8 deletions src/gpu/sdl/lv_gpu_sdl_lru.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
#include "../../lv_conf_internal.h"

#if LV_USE_GPU_SDL

#include "../../misc/lv_log.h"
#include "lv_gpu_sdl_lru.h"

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

/*********************
* DEFINES
Expand Down Expand Up @@ -69,12 +68,12 @@ static lruc_item * lv_lru_pop_or_create_item(lv_lru_t * cache);

/* lock helpers */
#define lock_cache() if(SDL_LockMutex(cache->mutex)) {\
perror("LRU Cache unable to obtain mutex lock");\
LV_LOG_WARN("LRU Cache unable to obtain mutex lock");\
return LV_LRU_LOCK_ERROR;\
}

#define unlock_cache() if(SDL_UnlockMutex(cache->mutex)) {\
perror("LRU Cache unable to release mutex lock");\
LV_LOG_WARN("LRU Cache unable to release mutex lock");\
return LV_LRU_LOCK_ERROR;\
}

Expand All @@ -89,7 +88,7 @@ lv_lru_t * lv_lru_new(uint64_t cache_size, uint32_t average_length, lv_lru_free_
// create the cache
lv_lru_t * cache = (lv_lru_t *) calloc(sizeof(lv_lru_t), 1);
if(!cache) {
perror("LRU Cache unable to create cache object");
LV_LOG_WARN("LRU Cache unable to create cache object");
return NULL;
}
cache->hash_table_size = cache_size / average_length;
Expand All @@ -103,15 +102,15 @@ lv_lru_t * lv_lru_new(uint64_t cache_size, uint32_t average_length, lv_lru_free_
// size the hash table to a guestimate of the number of slots required (assuming a perfect hash)
cache->items = (lruc_item **) calloc(sizeof(lruc_item *), cache->hash_table_size);
if(!cache->items) {
perror("LRU Cache unable to create cache hash table");
LV_LOG_WARN("LRU Cache unable to create cache hash table");
free(cache);
return NULL;
}

// all cache calls are guarded by a mutex
cache->mutex = SDL_CreateMutex();
if(!cache->mutex) {
perror("LRU Cache unable to initialise mutex");
LV_LOG_WARN("LRU Cache unable to initialise mutex");
free(cache->items);
free(cache);
return NULL;
Expand Down Expand Up @@ -295,6 +294,7 @@ static uint32_t lv_lru_hash(lv_lru_t * cache, const void * key, uint32_t key_len
case 1:
h ^= data[0];
h *= m;
break;
};

h ^= h >> 13;
Expand Down Expand Up @@ -372,4 +372,4 @@ static lruc_item * lv_lru_pop_or_create_item(lv_lru_t * cache)
return item;
}

#endif /*LV_USE_GPU_SDL*/
#endif /*LV_USE_GPU_SDL*/
2 changes: 1 addition & 1 deletion src/lv_conf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
# endif
#endif

/*Use SDL renderer API*/
/*Use SDL renderer API. Requires LV_USE_EXTERNAL_RENDERER*/
#ifndef LV_USE_GPU_SDL
# ifdef CONFIG_LV_USE_GPU_SDL
# define LV_USE_GPU_SDL CONFIG_LV_USE_GPU_SDL
Expand Down

0 comments on commit 924bc75

Please sign in to comment.