From e252eb75eb9324e02bdd1c210601501d76c927a6 Mon Sep 17 00:00:00 2001 From: "bernard.xiong" Date: Sun, 25 Oct 2009 23:26:04 +0000 Subject: [PATCH] remove some warning in compiling. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@136 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- rtgui/common/dc.c | 5 ++++- rtgui/common/filerw.c | 24 ++++++++++++++++++++++-- rtgui/common/image.c | 8 ++++---- rtgui/common/image_png.c | 4 +++- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/rtgui/common/dc.c b/rtgui/common/dc.c index 5701c56f4..0ccd51ebf 100644 --- a/rtgui/common/dc.c +++ b/rtgui/common/dc.c @@ -13,6 +13,9 @@ */ #include #include + +#include /* for strlen */ +#include /* fir qsort */ void rtgui_dc_destory(struct rtgui_dc* dc) { @@ -408,7 +411,7 @@ void rtgui_dc_draw_text (struct rtgui_dc* dc, const rt_uint8_t* text, struct rtg rtgui_font_derefer(gb2312_font); #else - len = strlen(text); + len = strlen((const char*)text); rtgui_font_draw(font, dc, text, len, &text_rect); #endif } diff --git a/rtgui/common/filerw.c b/rtgui/common/filerw.c index 09905f33b..a7656d853 100644 --- a/rtgui/common/filerw.c +++ b/rtgui/common/filerw.c @@ -302,7 +302,27 @@ rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context) } /* file read/write public interface */ -#ifdef RT_USING_DFS_FILERW +#ifdef RT_USING_DFS_FILERW +static int parse_mode(const char *mode) +{ + int f=0; + + for (;;) + { + switch (*mode) + { + case 0: return f; + case 'b': break; + case 'r': f=O_RDONLY; break; + case 'w': f=O_WRONLY|O_CREAT|O_TRUNC; break; + case 'a': f=O_WRONLY|O_CREAT|O_APPEND; break; + case '+': f=(f&(~O_WRONLY))|O_RDWR; break; + } + + ++mode; + } +} + struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* mode) { int fd; @@ -311,7 +331,7 @@ struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* RT_ASSERT(filename != RT_NULL); rw = RT_NULL; - fd = open(filename, mode, 0); + fd = open(filename, parse_mode(mode), 0); if ( fd >= 0 ) { diff --git a/rtgui/common/image.c b/rtgui/common/image.c index 5fd386049..9908c2962 100644 --- a/rtgui/common/image.c +++ b/rtgui/common/image.c @@ -12,11 +12,11 @@ * 2009-10-16 Bernard first version */ #include -#include - +#include + #include -#include - +#include + #include #ifdef RTGUI_IMAGE_BMP diff --git a/rtgui/common/image_png.c b/rtgui/common/image_png.c index 55fdc49c0..6ea8bab52 100644 --- a/rtgui/common/image_png.c +++ b/rtgui/common/image_png.c @@ -190,7 +190,9 @@ static rt_bool_t rtgui_image_png_load(struct rtgui_image* image, struct rtgui_fi { png->line_pixels = rtgui_malloc(image->w * sizeof(rtgui_color_t)); png->pixels = RT_NULL; - } + } + + return RT_TRUE; } static void rtgui_image_png_unload(struct rtgui_image* image)