[core] 使用rt_memcpy rt_memset代替memcpy memset

This commit is contained in:
Meco Man
2022-01-09 00:23:18 +08:00
committed by Bernard Xiong
parent bb1084556f
commit f89a162ea3
25 changed files with 86 additions and 86 deletions
+3 -3
View File
@@ -265,7 +265,7 @@ int dfs_elm_mkfs(rt_device_t dev_id)
/* [IN] Format options */
/* [-] Working buffer */
/* [IN] Size of working buffer */
memset(&opt, 0, sizeof(opt));
rt_memset(&opt, 0, sizeof(opt));
opt.fmt = FM_ANY|FM_SFD;
result = f_mkfs(logic_nbr, &opt, work, FF_MAX_SS);
rt_free(work); work = RT_NULL;
@@ -792,7 +792,7 @@ int dfs_elm_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
tmp >>= 6;
hour = tmp & 0x1F; /* bit[15:11] Hour(0..23) */
memset(&tm_file, 0, sizeof(tm_file));
rt_memset(&tm_file, 0, sizeof(tm_file));
tm_file.tm_year = year - 1900; /* Years since 1900 */
tm_file.tm_mon = mon - 1; /* Months *since* january: 0-11 */
tm_file.tm_mday = day; /* Day of the month: 1-31 */
@@ -957,7 +957,7 @@ DWORD get_fattime(void)
/* converts calendar time time into local time. */
p_tm = gmtime(&now);
/* copy the statically located variable */
memcpy(&tm_now, p_tm, sizeof(struct tm));
rt_memcpy(&tm_now, p_tm, sizeof(struct tm));
/* unlock scheduler. */
rt_exit_critical();
+3 -3
View File
@@ -106,7 +106,7 @@ int dfs_ramfs_read(struct dfs_fd *file, void *buf, size_t count)
length = file->size - file->pos;
if (length > 0)
memcpy(buf, &(dirent->data[file->pos]), length);
rt_memcpy(buf, &(dirent->data[file->pos]), length);
/* update file current position */
file->pos += length;
@@ -143,7 +143,7 @@ int dfs_ramfs_write(struct dfs_fd *fd, const void *buf, size_t count)
}
if (count > 0)
memcpy(dirent->data + fd->pos, buf, count);
rt_memcpy(dirent->data + fd->pos, buf, count);
/* update file current position */
fd->pos += count;
@@ -442,7 +442,7 @@ struct dfs_ramfs *dfs_ramfs_create(rt_uint8_t *pool, rt_size_t size)
ramfs->memheap.parent.type = RT_Object_Class_MemHeap | RT_Object_Class_Static;
/* initialize root directory */
memset(&(ramfs->root), 0x00, sizeof(ramfs->root));
rt_memset(&(ramfs->root), 0x00, sizeof(ramfs->root));
rt_list_init(&(ramfs->root.list));
ramfs->root.size = 0;
strcpy(ramfs->root.name, ".");
+1 -1
View File
@@ -147,7 +147,7 @@ int dfs_romfs_read(struct dfs_fd *file, void *buf, size_t count)
length = file->size - file->pos;
if (length > 0)
memcpy(buf, &(dirent->data[file->pos]), length);
rt_memcpy(buf, &(dirent->data[file->pos]), length);
/* update file current position */
file->pos += length;
+4 -4
View File
@@ -55,18 +55,18 @@ int dfs_init(void)
}
/* clear filesystem operations table */
memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table));
rt_memset((void *)filesystem_operation_table, 0, sizeof(filesystem_operation_table));
/* clear filesystem table */
memset(filesystem_table, 0, sizeof(filesystem_table));
rt_memset(filesystem_table, 0, sizeof(filesystem_table));
/* clean fd table */
memset(&_fdtab, 0, sizeof(_fdtab));
rt_memset(&_fdtab, 0, sizeof(_fdtab));
/* create device filesystem lock */
rt_mutex_init(&fslock, "fslock", RT_IPC_FLAG_PRIO);
#ifdef DFS_USING_WORKDIR
/* set current working directory */
memset(working_directory, 0, sizeof(working_directory));
rt_memset(working_directory, 0, sizeof(working_directory));
working_directory[0] = '/';
#endif
+5 -5
View File
@@ -543,11 +543,11 @@ void ls(const char *pathname)
rt_kprintf("Directory %s:\n", path);
do
{
memset(&dirent, 0, sizeof(struct dirent));
rt_memset(&dirent, 0, sizeof(struct dirent));
length = dfs_file_getdents(&fd, &dirent, sizeof(struct dirent));
if (length > 0)
{
memset(&stat, 0, sizeof(struct stat));
rt_memset(&stat, 0, sizeof(struct stat));
/* build full path for each file */
fullpath = dfs_normalize_path(path, dirent.d_name);
@@ -607,7 +607,7 @@ void cat(const char *filename)
do
{
memset(buffer, 0, sizeof(buffer));
rt_memset(buffer, 0, sizeof(buffer));
length = dfs_file_read(&fd, buffer, sizeof(buffer) - 1);
if (length > 0)
{
@@ -692,7 +692,7 @@ static void copydir(const char *src, const char *dst)
do
{
memset(&dirent, 0, sizeof(struct dirent));
rt_memset(&dirent, 0, sizeof(struct dirent));
length = dfs_file_getdents(&cpfd, &dirent, sizeof(struct dirent));
if (length > 0)
@@ -716,7 +716,7 @@ static void copydir(const char *src, const char *dst)
break;
}
memset(&stat, 0, sizeof(struct stat));
rt_memset(&stat, 0, sizeof(struct stat));
if (dfs_file_stat(src_entry_full, &stat) != 0)
{
rt_kprintf("open file: %s failed\n", dirent.d_name);
+4 -4
View File
@@ -323,7 +323,7 @@ int dfs_mount(const char *device_name,
{
/* The underlying device has error, clear the entry. */
dfs_lock();
memset(fs, 0, sizeof(struct dfs_filesystem));
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
goto err1;
}
@@ -339,7 +339,7 @@ int dfs_mount(const char *device_name,
/* mount failed */
dfs_lock();
/* clear filesystem table entry */
memset(fs, 0, sizeof(struct dfs_filesystem));
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
goto err1;
}
@@ -403,7 +403,7 @@ int dfs_unmount(const char *specialfile)
rt_free(fs->path);
/* clear this filesystem table entry */
memset(fs, 0, sizeof(struct dfs_filesystem));
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
dfs_unlock();
rt_free(fullpath);
@@ -590,7 +590,7 @@ int dfs_unmount_device(rt_device_t dev)
rt_free(fs->path);
/* clear this filesystem table entry */
memset(fs, 0, sizeof(struct dfs_filesystem));
rt_memset(fs, 0, sizeof(struct dfs_filesystem));
dfs_unlock();
+1 -1
View File
@@ -639,7 +639,7 @@ DIR *opendir(const char *name)
}
else
{
memset(t, 0, sizeof(DIR));
rt_memset(t, 0, sizeof(DIR));
t->fd = fd;
}