Procházet zdrojové kódy

remove some warning in compiling.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@136 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong před 15 roky
rodič
revize
e252eb75eb
4 změnil soubory, kde provedl 33 přidání a 8 odebrání
  1. 4 1
      rtgui/common/dc.c
  2. 22 2
      rtgui/common/filerw.c
  3. 4 4
      rtgui/common/image.c
  4. 3 1
      rtgui/common/image_png.c

+ 4 - 1
rtgui/common/dc.c

@@ -13,6 +13,9 @@
  */
 #include <rtgui/dc.h>
 #include <rtgui/rtgui_system.h>
+
+#include <string.h>	/* for strlen */
+#include <stdlib.h>	/* 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
 }

+ 22 - 2
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 )
 	{

+ 4 - 4
rtgui/common/image.c

@@ -12,11 +12,11 @@
  * 2009-10-16     Bernard      first version
  */
 #include <rtthread.h>
-#include <rtgui/image.h>
-
+#include <rtgui/image.h>
+
 #include <rtgui/image_xpm.h>
-#include <rtgui/rtgui_system.h>
-
+#include <rtgui/rtgui_system.h>
+
 #include <string.h>
 
 #ifdef RTGUI_IMAGE_BMP

+ 3 - 1
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)