From 77f4ee30291455521773a3c16818a78df8c3092f Mon Sep 17 00:00:00 2001 From: "goprife@gmail.com" Date: Sat, 29 Dec 2012 04:12:47 +0000 Subject: [PATCH] fix compile warnings in bsp/simulator git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2544 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/simulator/applications/dfs_win32.c | 2 +- bsp/simulator/applications/platform.c | 2 -- bsp/simulator/drivers/sd_sim.c | 1 - bsp/simulator/drivers/serial.c | 20 ++++++++++++++------ bsp/simulator/drivers/usart_sim.c | 2 ++ bsp/simulator/rtconfig.h | 10 +++++++++- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/bsp/simulator/applications/dfs_win32.c b/bsp/simulator/applications/dfs_win32.c index be9afb882..c94ed71aa 100644 --- a/bsp/simulator/applications/dfs_win32.c +++ b/bsp/simulator/applications/dfs_win32.c @@ -187,7 +187,7 @@ static int dfs_win32_close(struct dfs_fd *file) if (oflag & DFS_O_DIRECTORY) { /* operations about dir */ - if (_findclose(file->data) < 0) + if (_findclose((intptr_t)file->data) < 0) goto __err; return 0; diff --git a/bsp/simulator/applications/platform.c b/bsp/simulator/applications/platform.c index cc2a56b8e..d178f28ec 100644 --- a/bsp/simulator/applications/platform.c +++ b/bsp/simulator/applications/platform.c @@ -25,7 +25,5 @@ void rt_platform_init(void) #ifdef _WIN32 rt_thread_idle_sethook(rt_hw_win32_low_cpu); #endif - rt_thread_delay(50); - rt_device_init_all(); } diff --git a/bsp/simulator/drivers/sd_sim.c b/bsp/simulator/drivers/sd_sim.c index 47822d3e3..a9e327ad5 100644 --- a/bsp/simulator/drivers/sd_sim.c +++ b/bsp/simulator/drivers/sd_sim.c @@ -126,7 +126,6 @@ static rt_err_t rt_sdcard_control(rt_device_t dev, rt_uint8_t cmd, void *args) rt_err_t rt_hw_sdcard_init(const char *spi_device_name) { int size; - rt_uint32_t id, total_block; struct sdcard_device *sd; struct rt_device *device; diff --git a/bsp/simulator/drivers/serial.c b/bsp/simulator/drivers/serial.c index a5643a46d..96ea5e743 100644 --- a/bsp/simulator/drivers/serial.c +++ b/bsp/simulator/drivers/serial.c @@ -2,17 +2,19 @@ ****************************************************************************** * By : parai * email:parai@foxmail.com -* 这并不是一个真的串口设备,只是为了能够让内核打印信息而创建 +* virtual serial driver ****************************************************************************** */ -#include "rtthread.h" +#include +#include #define _DEBUG_SERIAL 0 #include "serial.h" #include struct rt_device serial_device; extern struct serial_int_rx serial_rx; +static FILE *fp = RT_NULL; /*@{*/ @@ -107,8 +109,14 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buff #if _DEBUG_SERIAL==1 printf("in rt_serial_write()\n"); #endif - printf("%s", (char *)buffer); - return size; + if (fp == NULL) + fp = fopen("log.txt", "wb+"); + + if (fp != NULL) + fwrite(buffer, size, 1, fp); + + printf("%s",(char*)buffer); + return size; } static rt_err_t rt_serial_control(rt_device_t dev, rt_uint8_t cmd, void *args) @@ -152,11 +160,11 @@ static rt_err_t rt_hw_serial_register(rt_device_t device, const char *name, rt_u device->user_data = RT_NULL; /* register a character device */ - return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag); + return rt_device_register(device, name, (rt_uint16_t)(RT_DEVICE_FLAG_RDWR | flag)); } rt_err_t rt_hw_serial_init(void) { return rt_hw_serial_register(&serial_device, RT_CONSOLE_DEVICE_NAME, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM); -} \ No newline at end of file +} diff --git a/bsp/simulator/drivers/usart_sim.c b/bsp/simulator/drivers/usart_sim.c index e13793acd..9568f213c 100644 --- a/bsp/simulator/drivers/usart_sim.c +++ b/bsp/simulator/drivers/usart_sim.c @@ -1,7 +1,9 @@ +#include #include #include #include #include + #include "serial.h" struct serial_int_rx serial_rx; diff --git a/bsp/simulator/rtconfig.h b/bsp/simulator/rtconfig.h index ded6b25da..df9a018ac 100644 --- a/bsp/simulator/rtconfig.h +++ b/bsp/simulator/rtconfig.h @@ -10,6 +10,14 @@ #define _CRT_ERRNO_DEFINED //errno macro redefinition #define HEAP_SIZE (1024*1024*2) + +/* disable some warning in MSC */ +#pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */ +#pragma warning(disable:4312) /* to ignore: warning C4312: 'type cast' : conversion from 'rt_uint32_t' to 'rt_uint32_t *' */ +#pragma warning(disable:4311) /* to ignore: warning C4311: 'type cast' : pointer truncation from 'short *__w64 ' to 'long' */ +#pragma warning(disable:4996) /* to ignore: warning C4996: The POSIX name for this item is deprecated. */ +#pragma warning(disable:4267) /* to ignore: warning C4267: conversion from 'size_t' to 'rt_size_t', possible loss of data */ +#pragma warning(disable:4244) /* to ignore: warning C4244: '=' : conversion from '__w64 int' to 'rt_size_t', possible loss of data */ #endif /* SECTION: basic kernel options */ @@ -113,7 +121,7 @@ #define RT_USING_DFS_NFS /* DFS: uffs nand file system options */ -/* #define RT_USING_DFS_UFFS */ +#define RT_USING_DFS_UFFS /* configuration for uffs, more to see dfs_uffs.h and uffs_config.h */ /* use ecc soft, the uffs will do all the things about ecc */ #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT