diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index 45195f3c2917b3c7575608703295299b71ea9d5b..f5d469fd5f0da2029e5193bcce1e96804c919782 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -4,10 +4,6 @@ #include "devfs.h" -/* introduce from kservice.c */ -#define rt_list_entry(node, type, member) \ - ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member))) - struct device_dirent { rt_device_t *devices; @@ -15,12 +11,12 @@ struct device_dirent rt_uint16_t device_count; }; -int dfs_device_fs_mount(struct dfs_filesystem* fs, unsigned long rwflag, const void* data) +int dfs_device_fs_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data) { return DFS_STATUS_OK; } -int dfs_device_fs_ioctl(struct dfs_fd* file, int cmd, void* args) +int dfs_device_fs_ioctl(struct dfs_fd *file, int cmd, void *args) { rt_err_t result; rt_device_t dev_id; @@ -39,7 +35,7 @@ int dfs_device_fs_ioctl(struct dfs_fd* file, int cmd, void* args) return -DFS_STATUS_EIO; } -int dfs_device_fs_read(struct dfs_fd* file, void *buf, rt_size_t count) +int dfs_device_fs_read(struct dfs_fd *file, void *buf, rt_size_t count) { int result; rt_device_t dev_id; @@ -57,7 +53,7 @@ int dfs_device_fs_read(struct dfs_fd* file, void *buf, rt_size_t count) return result; } -int dfs_device_fs_write(struct dfs_fd* file, const void *buf, rt_size_t count) +int dfs_device_fs_write(struct dfs_fd *file, const void *buf, rt_size_t count) { int result; rt_device_t dev_id; @@ -75,7 +71,7 @@ int dfs_device_fs_write(struct dfs_fd* file, const void *buf, rt_size_t count) return result; } -int dfs_device_fs_close(struct dfs_fd* file) +int dfs_device_fs_close(struct dfs_fd *file) { rt_err_t result; rt_device_t dev_id; @@ -86,7 +82,7 @@ int dfs_device_fs_close(struct dfs_fd* file) { struct device_dirent *root_dirent; - root_dirent = (struct device_dirent*)file->data; + root_dirent = (struct device_dirent *)file->data; RT_ASSERT(root_dirent != RT_NULL); /* release dirent */ @@ -103,26 +99,28 @@ int dfs_device_fs_close(struct dfs_fd* file) if (result == RT_EOK) { file->data = RT_NULL; + return DFS_STATUS_OK; } return -DFS_STATUS_EIO; } -int dfs_device_fs_open(struct dfs_fd* file) +int dfs_device_fs_open(struct dfs_fd *file) { rt_device_t device; - if (file->flags & DFS_O_CREAT) return -DFS_STATUS_EINVAL; + if (file->flags & DFS_O_CREAT) + return -DFS_STATUS_EINVAL; /* open root directory */ if ((file->path[0] == '/') && (file->path[1] == '\0') && (file->flags & DFS_O_DIRECTORY)) { - struct rt_object* object; - struct rt_list_node* node; + struct rt_object *object; + struct rt_list_node *node; struct rt_object_information *information; - struct device_dirent* root_dirent; + struct device_dirent *root_dirent; rt_uint32_t count = 0; extern struct rt_object_information rt_object_container[]; @@ -137,7 +135,7 @@ int dfs_device_fs_open(struct dfs_fd* file) count ++; } - root_dirent = (struct device_dirent*) rt_malloc (sizeof(struct device_dirent) + + root_dirent = (struct device_dirent *)rt_malloc(sizeof(struct device_dirent) + count * sizeof(rt_device_t)); if (root_dirent != RT_NULL) { @@ -157,6 +155,7 @@ int dfs_device_fs_open(struct dfs_fd* file) /* set data */ file->data = root_dirent; + return DFS_STATUS_OK; } @@ -165,15 +164,16 @@ int dfs_device_fs_open(struct dfs_fd* file) return -DFS_STATUS_ENODEV; file->data = device; + return DFS_STATUS_OK; } -int dfs_device_fs_stat(struct dfs_filesystem* fs, const char *path, struct stat *st) +int dfs_device_fs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st) { /* stat root directory */ if ((path[0] == '/') && (path[1] == '\0')) { - st->st_dev = 0; + st->st_dev = 0; st->st_mode = DFS_S_IFREG | DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH | DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH; @@ -183,6 +183,7 @@ int dfs_device_fs_stat(struct dfs_filesystem* fs, const char *path, struct stat st->st_size = 0; st->st_mtime = 0; st->st_blksize = 512; + return DFS_STATUS_OK; } else @@ -192,7 +193,7 @@ int dfs_device_fs_stat(struct dfs_filesystem* fs, const char *path, struct stat dev_id = rt_device_find(&path[1]); if (dev_id != RT_NULL) { - st->st_dev = 0; + st->st_dev = 0; st->st_mode = DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH | DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH; @@ -207,6 +208,7 @@ int dfs_device_fs_stat(struct dfs_filesystem* fs, const char *path, struct stat st->st_size = 0; st->st_mtime = 0; st->st_blksize = 512; + return DFS_STATUS_OK; } } @@ -214,19 +216,20 @@ int dfs_device_fs_stat(struct dfs_filesystem* fs, const char *path, struct stat return -DFS_STATUS_ENOENT; } -int dfs_device_fs_getdents(struct dfs_fd* file, struct dirent* dirp, rt_uint32_t count) +int dfs_device_fs_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count) { rt_uint32_t index; rt_object_t object; - struct dirent* d; + struct dirent *d; struct device_dirent *root_dirent; - root_dirent = (struct device_dirent*)file->data; + root_dirent = (struct device_dirent *)file->data; RT_ASSERT(root_dirent != RT_NULL); /* make integer count */ count = (count / sizeof(struct dirent)); - if ( count == 0 ) return -DFS_STATUS_EINVAL; + if (count == 0) + return -DFS_STATUS_EINVAL; for (index = 0; index < count && index + root_dirent->read_index < root_dirent->device_count; index ++) @@ -269,8 +272,8 @@ static const struct dfs_filesystem_operation _device_fs = int devfs_init(void) { - /* register rom file system */ - dfs_register(&_device_fs); + /* register rom file system */ + dfs_register(&_device_fs); return 0; } diff --git a/components/net/lwip-1.3.2/src/arch/sys_arch_init.c b/components/net/lwip-1.3.2/src/arch/sys_arch_init.c index ebb38898a24047d097f16ab98c9b1cfeafd4d8f6..0b4669afde7170ae59509a02f9e49bf000d98bc6 100644 --- a/components/net/lwip-1.3.2/src/arch/sys_arch_init.c +++ b/components/net/lwip-1.3.2/src/arch/sys_arch_init.c @@ -11,10 +11,6 @@ #include "netif/ethernetif.h" #include "netif/etharp.h" -/* introduce from kservice.c */ -#define rt_list_entry(node, type, member) \ - ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member))) - static err_t netif_device_init(struct netif *netif) { struct eth_device *ethif; diff --git a/components/net/lwip/src/arch/sys_arch.c b/components/net/lwip/src/arch/sys_arch.c index 21d4103a44957da5089bdaebd5f0a1fcbd730c46..1eb3c1cfeaa69f5933969e890721d9a4f7aa1894 100644 --- a/components/net/lwip/src/arch/sys_arch.c +++ b/components/net/lwip/src/arch/sys_arch.c @@ -12,10 +12,6 @@ #include -/* introduce from kservice.c */ -#define rt_list_entry(node, type, member) \ - ((type *)((char *)(node) - (unsigned long)(&((type *)0)->member))) - static err_t netif_device_init(struct netif *netif) { struct eth_device *ethif;