diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index b7cdaf8522..eb57034061 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -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(); diff --git a/components/dfs/filesystems/ramfs/dfs_ramfs.c b/components/dfs/filesystems/ramfs/dfs_ramfs.c index cc58590de2..781626633f 100644 --- a/components/dfs/filesystems/ramfs/dfs_ramfs.c +++ b/components/dfs/filesystems/ramfs/dfs_ramfs.c @@ -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, "."); diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index 2e9b08cbf6..9e355471a8 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -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; diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c index d3a859e287..0299465a99 100644 --- a/components/dfs/src/dfs.c +++ b/components/dfs/src/dfs.c @@ -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 diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index 711a461e20..a798bd3c59 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -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); diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index 53e7e385a4..2abad9dfeb 100644 --- a/components/dfs/src/dfs_fs.c +++ b/components/dfs/src/dfs_fs.c @@ -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(); diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c index e6336c2544..5b26f190ce 100644 --- a/components/dfs/src/dfs_posix.c +++ b/components/dfs/src/dfs_posix.c @@ -639,7 +639,7 @@ DIR *opendir(const char *name) } else { - memset(t, 0, sizeof(DIR)); + rt_memset(t, 0, sizeof(DIR)); t->fd = fd; } diff --git a/components/drivers/audio/audio.c b/components/drivers/audio/audio.c index f9d42aeb5c..edef7d0eeb 100644 --- a/components/drivers/audio/audio.c +++ b/components/drivers/audio/audio.c @@ -52,14 +52,14 @@ static rt_err_t _audio_send_replay_frame(struct rt_audio_device *audio) rt_completion_done(&audio->replay->cmp); /* send zero frames */ - memset(&buf_info->buffer[audio->replay->pos], 0, dst_size); + rt_memset(&buf_info->buffer[audio->replay->pos], 0, dst_size); audio->replay->pos += dst_size; audio->replay->pos %= buf_info->total_size; } else { - memset(&buf_info->buffer[audio->replay->pos], 0, dst_size); + rt_memset(&buf_info->buffer[audio->replay->pos], 0, dst_size); /* copy data from memory pool to hardware device fifo */ while (index < dst_size) @@ -77,7 +77,7 @@ static rt_err_t _audio_send_replay_frame(struct rt_audio_device *audio) } remain_bytes = MIN((dst_size - index), (src_size - audio->replay->read_index)); - memcpy(&buf_info->buffer[audio->replay->pos], + rt_memcpy(&buf_info->buffer[audio->replay->pos], &data[audio->replay->read_index], remain_bytes); index += remain_bytes; @@ -229,7 +229,7 @@ static rt_err_t _audio_dev_init(struct rt_device *dev) if (replay == RT_NULL) return -RT_ENOMEM; - memset(replay, 0, sizeof(struct rt_audio_replay)); + rt_memset(replay, 0, sizeof(struct rt_audio_replay)); /* init memory pool for replay */ replay->mp = rt_mp_create("adu_mp", RT_AUDIO_REPLAY_MP_BLOCK_COUNT, RT_AUDIO_REPLAY_MP_BLOCK_SIZE); @@ -258,7 +258,7 @@ static rt_err_t _audio_dev_init(struct rt_device *dev) if (record == RT_NULL) return -RT_ENOMEM; - memset(record, 0, sizeof(struct rt_audio_record)); + rt_memset(record, 0, sizeof(struct rt_audio_record)); /* init pipe for record*/ buffer = rt_malloc(RT_AUDIO_RECORD_PIPE_SIZE); @@ -393,12 +393,12 @@ static rt_size_t _audio_dev_write(struct rt_device *dev, rt_off_t pos, const voi if (audio->replay->write_index % block_size == 0) { audio->replay->write_data = rt_mp_alloc(audio->replay->mp, RT_WAITING_FOREVER); - memset(audio->replay->write_data, 0, block_size); + rt_memset(audio->replay->write_data, 0, block_size); } /* copy data to replay memory pool */ remain_bytes = MIN((block_size - audio->replay->write_index), (size - index)); - memcpy(&audio->replay->write_data[audio->replay->write_index], &ptr[index], remain_bytes); + rt_memcpy(&audio->replay->write_data[audio->replay->write_index], &ptr[index], remain_bytes); index += remain_bytes; audio->replay->write_index += remain_bytes; diff --git a/components/drivers/misc/rt_drv_pwm.c b/components/drivers/misc/rt_drv_pwm.c index 42325587ab..c60bf6df1d 100644 --- a/components/drivers/misc/rt_drv_pwm.c +++ b/components/drivers/misc/rt_drv_pwm.c @@ -105,7 +105,7 @@ rt_err_t rt_device_pwm_register(struct rt_device_pwm *device, const char *name, { rt_err_t result = RT_EOK; - memset(device, 0, sizeof(struct rt_device_pwm)); + rt_memset(device, 0, sizeof(struct rt_device_pwm)); #ifdef RT_USING_DEVICE_OPS device->parent.ops = &pwm_device_ops; diff --git a/components/drivers/rtc/soft_rtc.c b/components/drivers/rtc/soft_rtc.c index 255579f35e..02b5cbec53 100644 --- a/components/drivers/rtc/soft_rtc.c +++ b/components/drivers/rtc/soft_rtc.c @@ -61,7 +61,7 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args) struct tm time_temp; RT_ASSERT(dev != RT_NULL); - memset(&time_temp, 0, sizeof(struct tm)); + rt_memset(&time_temp, 0, sizeof(struct tm)); switch (cmd) { diff --git a/components/drivers/spi/enc28j60.c b/components/drivers/spi/enc28j60.c index f8e5582e10..0a63010a5c 100644 --- a/components/drivers/spi/enc28j60.c +++ b/components/drivers/spi/enc28j60.c @@ -778,7 +778,7 @@ rt_err_t enc28j60_attach(const char *spi_device_name) rt_spi_configure(spi_device, &cfg); } /* config spi */ - memset(&enc28j60_dev, 0, sizeof(enc28j60_dev)); + rt_memset(&enc28j60_dev, 0, sizeof(enc28j60_dev)); rt_event_init(&tx_event, "eth_tx", RT_IPC_FLAG_FIFO); enc28j60_dev.spi_device = spi_device; diff --git a/components/drivers/spi/sfud/src/sfud.c b/components/drivers/spi/sfud/src/sfud.c index 4078179262..d28f36d620 100644 --- a/components/drivers/spi/sfud/src/sfud.c +++ b/components/drivers/spi/sfud/src/sfud.c @@ -650,7 +650,7 @@ static sfud_err page256_or_1_byte_write(const sfud_flash *flash, uint32_t addr, size -= data_size; addr += data_size; - memcpy(&cmd_data[cmd_size], data, data_size); + rt_memcpy(&cmd_data[cmd_size], data, data_size); result = spi->wr(spi, cmd_data, cmd_size + data_size, NULL, 0); if (result != SFUD_SUCCESS) { diff --git a/components/drivers/spi/spi_msd.c b/components/drivers/spi/spi_msd.c index 875ae3c486..6bd0501694 100644 --- a/components/drivers/spi/spi_msd.c +++ b/components/drivers/spi/spi_msd.c @@ -500,7 +500,7 @@ static rt_err_t rt_msd_init(rt_device_t dev) uint8_t send_buffer[100]; /* 100byte > 74 clock */ /* initial message */ - memset(send_buffer, DUMMY, sizeof(send_buffer)); + rt_memset(send_buffer, DUMMY, sizeof(send_buffer)); message.send_buf = send_buffer; message.recv_buf = RT_NULL; message.length = sizeof(send_buffer); @@ -697,7 +697,7 @@ static rt_err_t rt_msd_init(rt_device_t dev) uint8_t send_buffer[100]; /* initial message */ - memset(send_buffer, DUMMY, sizeof(send_buffer)); + rt_memset(send_buffer, DUMMY, sizeof(send_buffer)); message.send_buf = send_buffer; message.recv_buf = RT_NULL; message.length = sizeof(send_buffer); diff --git a/components/drivers/spi/spi_wifi_rw009.c b/components/drivers/spi/spi_wifi_rw009.c index 84da212077..20dd6d7f93 100644 --- a/components/drivers/spi/spi_wifi_rw009.c +++ b/components/drivers/spi/spi_wifi_rw009.c @@ -94,7 +94,7 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp WIFI_DEBUG("resp_handler RW009_CMD_INIT\n"); resp_return = (struct rw009_resp *)rt_malloc(member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_init)); //TODO: if(resp_return == RT_NULL) break; - memcpy(resp_return, resp, member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_init)); + rt_memcpy(resp_return, resp, member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_init)); WIFI_DEBUG("sn:%-*.*s\n", sizeof(resp->resp.init.sn), sizeof(resp->resp.init.sn), resp->resp.init.sn); WIFI_DEBUG("version:%-*.*s\n", sizeof(resp->resp.init.version), sizeof(resp->resp.init.version), resp->resp.init.version); @@ -108,7 +108,7 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp rw009_ap_info *ap_scan = rt_realloc(wifi_device->ap_scan, sizeof(rw009_ap_info) * (wifi_device->ap_scan_count + 1) ); if(ap_scan != RT_NULL) { - memcpy( &ap_scan[wifi_device->ap_scan_count], &resp->resp.ap_info, sizeof(rw009_ap_info) ); + rt_memcpy( &ap_scan[wifi_device->ap_scan_count], &resp->resp.ap_info, sizeof(rw009_ap_info) ); //dump if(1) @@ -142,11 +142,11 @@ static void resp_handler(struct rw009_wifi *wifi_device, struct rw009_resp *resp WIFI_DEBUG("resp_handler RW009_CMD_EASY_JOIN\n"); resp_return = (struct rw009_resp *)rt_malloc(member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_join)); //TODO: if(resp_return == RT_NULL) break; - memcpy(resp_return, resp, member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_join)); + rt_memcpy(resp_return, resp, member_offset(struct rw009_resp, resp) + sizeof(rw009_resp_join)); if( resp->result == 0 ) { - memcpy(&wifi_device->ap_info, &resp_return->resp.ap_info, sizeof(rw009_resp_join)); + rt_memcpy(&wifi_device->ap_info, &resp_return->resp.ap_info, sizeof(rw009_resp_join)); wifi_device->active = 1; eth_device_linkchange(&wifi_device->parent, RT_TRUE); } @@ -284,7 +284,7 @@ static rt_err_t rw009_cmd(struct rw009_wifi *wifi_device, uint32_t cmd, void *ar } if(wifi_cmd->len) - memcpy(&wifi_cmd->params, args, wifi_cmd->len); + rt_memcpy(&wifi_cmd->params, args, wifi_cmd->len); data_packet->data_type = data_type_cmd; data_packet->data_len = member_offset(struct rw009_cmd, params) + wifi_cmd->len; @@ -326,7 +326,7 @@ static rt_err_t spi_wifi_transfer(struct rw009_wifi *dev) while (spi_wifi_is_busy()); SPI_DEBUG("sequence start!\n"); - memset(&cmd, 0, sizeof(struct spi_cmd_request)); + rt_memset(&cmd, 0, sizeof(struct spi_cmd_request)); cmd.magic1 = CMD_MAGIC1; cmd.magic2 = CMD_MAGIC2; @@ -523,7 +523,7 @@ static rt_err_t rw009_wifi_control(rt_device_t dev, int cmd, void *args) if (cmd == NIOCTL_GADDR) { - memcpy(args, wifi_device->dev_addr, 6); + rt_memcpy(args, wifi_device->dev_addr, 6); } else { @@ -633,7 +633,7 @@ rt_err_t rt_hw_wifi_init(const char *spi_device_name, wifi_mode_t mode) RT_ASSERT( (SPI_MAX_DATA_LEN & 0x03) == 0); RT_ASSERT( sizeof(struct rw009_resp) <= SPI_MAX_DATA_LEN); - memset(&rw009_wifi_device, 0, sizeof(struct rw009_wifi)); + rt_memset(&rw009_wifi_device, 0, sizeof(struct rw009_wifi)); rw009_wifi_device.rt_spi_device = (struct rt_spi_device *)rt_device_find(spi_device_name); diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c index e33f533db0..deb8979930 100644 --- a/components/drivers/src/ringbuffer.c +++ b/components/drivers/src/ringbuffer.c @@ -83,17 +83,17 @@ rt_size_t rt_ringbuffer_put(struct rt_ringbuffer *rb, if (rb->buffer_size - rb->write_index > length) { /* read_index - write_index = empty space */ - memcpy(&rb->buffer_ptr[rb->write_index], ptr, length); + rt_memcpy(&rb->buffer_ptr[rb->write_index], ptr, length); /* this should not cause overflow because there is enough space for * length of data in current mirror */ rb->write_index += length; return length; } - memcpy(&rb->buffer_ptr[rb->write_index], + rt_memcpy(&rb->buffer_ptr[rb->write_index], &ptr[0], rb->buffer_size - rb->write_index); - memcpy(&rb->buffer_ptr[0], + rt_memcpy(&rb->buffer_ptr[0], &ptr[rb->buffer_size - rb->write_index], length - (rb->buffer_size - rb->write_index)); @@ -133,7 +133,7 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb, if (rb->buffer_size - rb->write_index > length) { /* read_index - write_index = empty space */ - memcpy(&rb->buffer_ptr[rb->write_index], ptr, length); + rt_memcpy(&rb->buffer_ptr[rb->write_index], ptr, length); /* this should not cause overflow because there is enough space for * length of data in current mirror */ rb->write_index += length; @@ -144,10 +144,10 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb, return length; } - memcpy(&rb->buffer_ptr[rb->write_index], + rt_memcpy(&rb->buffer_ptr[rb->write_index], &ptr[0], rb->buffer_size - rb->write_index); - memcpy(&rb->buffer_ptr[0], + rt_memcpy(&rb->buffer_ptr[0], &ptr[rb->buffer_size - rb->write_index], length - (rb->buffer_size - rb->write_index)); @@ -197,17 +197,17 @@ rt_size_t rt_ringbuffer_get(struct rt_ringbuffer *rb, if (rb->buffer_size - rb->read_index > length) { /* copy all of data */ - memcpy(ptr, &rb->buffer_ptr[rb->read_index], length); + rt_memcpy(ptr, &rb->buffer_ptr[rb->read_index], length); /* this should not cause overflow because there is enough space for * length of data in current mirror */ rb->read_index += length; return length; } - memcpy(&ptr[0], + rt_memcpy(&ptr[0], &rb->buffer_ptr[rb->read_index], rb->buffer_size - rb->read_index); - memcpy(&ptr[rb->buffer_size - rb->read_index], + rt_memcpy(&ptr[rb->buffer_size - rb->read_index], &rb->buffer_ptr[0], length - (rb->buffer_size - rb->read_index)); diff --git a/components/drivers/usb/usbdevice/class/rndis.c b/components/drivers/usb/usbdevice/class/rndis.c index ee25ec1ddf..69ca3f5d69 100644 --- a/components/drivers/usb/usbdevice/class/rndis.c +++ b/components/drivers/usb/usbdevice/class/rndis.c @@ -376,7 +376,7 @@ static rndis_query_cmplt_t _create_resp(rt_size_t size) static void _copy_resp(rndis_query_cmplt_t resp, const void * buffer) { char * resp_buffer = (char *)resp + sizeof(struct rndis_query_cmplt); - memcpy(resp_buffer, buffer, resp->InformationBufferLength); + rt_memcpy(resp_buffer, buffer, resp->InformationBufferLength); } static void _set_resp(rndis_query_cmplt_t resp, rt_uint32_t value) @@ -897,13 +897,13 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size) data += sizeof(struct rndis_packet_msg); size -= sizeof(struct rndis_packet_msg); ((rt_rndis_eth_t)func->user_data)->rx_frist = RT_FALSE; - memcpy(&((rt_rndis_eth_t)func->user_data)->rx_buffer[((rt_rndis_eth_t)func->user_data)->rx_offset], data, size); + rt_memcpy(&((rt_rndis_eth_t)func->user_data)->rx_buffer[((rt_rndis_eth_t)func->user_data)->rx_offset], data, size); ((rt_rndis_eth_t)func->user_data)->rx_offset += size; } } else { - memcpy(&((rt_rndis_eth_t)func->user_data)->rx_buffer[((rt_rndis_eth_t)func->user_data)->rx_offset], data, size); + rt_memcpy(&((rt_rndis_eth_t)func->user_data)->rx_buffer[((rt_rndis_eth_t)func->user_data)->rx_offset], data, size); ((rt_rndis_eth_t)func->user_data)->rx_offset += size; } @@ -1137,7 +1137,7 @@ struct pbuf *rt_rndis_eth_rx(rt_device_t dev) for (q = p; q != RT_NULL; q= q->next) { /* Copy the received frame into buffer from memory pointed by the current ETHERNET DMA Rx descriptor */ - memcpy(q->payload, + rt_memcpy(q->payload, (rt_uint8_t *)((device->rx_buffer) + offset), q->len); offset += q->len; @@ -1191,7 +1191,7 @@ rt_err_t rt_rndis_eth_tx(rt_device_t dev, struct pbuf* p) buffer = (char *)&device->tx_buffer + sizeof(struct rndis_packet_msg); for (q = p; q != NULL; q = q->next) { - memcpy(buffer, q->payload, q->len); + rt_memcpy(buffer, q->payload, q->len); buffer += q->len; } diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 27e937f750..acb5445ad1 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -207,7 +207,7 @@ int msh_exec_module(const char *cmd_line, int size) return -RT_ENOMEM; /* copy command0 */ - memcpy(pg_name, cmd_line, cmd_length); + rt_memcpy(pg_name, cmd_line, cmd_length); pg_name[cmd_length] = '\0'; if (strstr(pg_name, ".mo") != RT_NULL || strstr(pg_name, ".MO") != RT_NULL) @@ -276,7 +276,7 @@ static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp) return -RT_ERROR; /* split arguments */ - memset(argv, 0x00, sizeof(argv)); + rt_memset(argv, 0x00, sizeof(argv)); argc = msh_split(cmd, length, argv); if (argc == 0) return -RT_ERROR; @@ -509,7 +509,7 @@ void msh_auto_complete_path(char *path) } length = index - path; - memcpy(index, full_path, min_length); + rt_memcpy(index, full_path, min_length); path[length + min_length] = '\0'; } } diff --git a/components/finsh/msh_file.c b/components/finsh/msh_file.c index 2b359fb4bc..8022b176fc 100644 --- a/components/finsh/msh_file.c +++ b/components/finsh/msh_file.c @@ -78,7 +78,7 @@ int msh_exec_script(const char *cmd_line, int size) if (pg_name == RT_NULL) return -RT_ENOMEM; /* copy command0 */ - memcpy(pg_name, cmd_line, cmd_length); + rt_memcpy(pg_name, cmd_line, cmd_length); pg_name[cmd_length] = '\0'; if (strstr(pg_name, ".sh") != RT_NULL || strstr(pg_name, ".SH") != RT_NULL) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 5b96d0daf9..5398db5370 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -221,7 +221,7 @@ void finsh_set_device(const char *device_name) } /* clear line buffer before switch to new device */ - memset(shell->line, 0, sizeof(shell->line)); + rt_memset(shell->line, 0, sizeof(shell->line)); shell->line_curpos = shell->line_position = 0; shell->device = dev; @@ -404,11 +404,11 @@ static void shell_push_history(struct finsh_shell *shell) int index; for (index = 0; index < FINSH_HISTORY_LINES - 1; index ++) { - memcpy(&shell->cmd_history[index][0], + rt_memcpy(&shell->cmd_history[index][0], &shell->cmd_history[index + 1][0], FINSH_CMD_SIZE); } - memset(&shell->cmd_history[index][0], 0, FINSH_CMD_SIZE); - memcpy(&shell->cmd_history[index][0], shell->line, shell->line_position); + rt_memset(&shell->cmd_history[index][0], 0, FINSH_CMD_SIZE); + rt_memcpy(&shell->cmd_history[index][0], shell->line, shell->line_position); /* it's the maximum history */ shell->history_count = FINSH_HISTORY_LINES; @@ -420,8 +420,8 @@ static void shell_push_history(struct finsh_shell *shell) if (shell->history_count == 0 || memcmp(&shell->cmd_history[shell->history_count - 1], shell->line, FINSH_CMD_SIZE)) { shell->current_history = shell->history_count; - memset(&shell->cmd_history[shell->history_count][0], 0, FINSH_CMD_SIZE); - memcpy(&shell->cmd_history[shell->history_count][0], shell->line, shell->line_position); + rt_memset(&shell->cmd_history[shell->history_count][0], 0, FINSH_CMD_SIZE); + rt_memcpy(&shell->cmd_history[shell->history_count][0], shell->line, shell->line_position); /* increase count and set current history position */ shell->history_count ++; @@ -517,7 +517,7 @@ void finsh_thread_entry(void *parameter) } /* copy the history command */ - memcpy(shell->line, &shell->cmd_history[shell->current_history][0], + rt_memcpy(shell->line, &shell->cmd_history[shell->current_history][0], FINSH_CMD_SIZE); shell->line_curpos = shell->line_position = strlen(shell->line); shell_handle_history(shell); @@ -539,7 +539,7 @@ void finsh_thread_entry(void *parameter) continue; } - memcpy(shell->line, &shell->cmd_history[shell->current_history][0], + rt_memcpy(shell->line, &shell->cmd_history[shell->current_history][0], FINSH_CMD_SIZE); shell->line_curpos = shell->line_position = strlen(shell->line); shell_handle_history(shell); @@ -630,7 +630,7 @@ void finsh_thread_entry(void *parameter) msh_exec(shell->line, shell->line_position); rt_kprintf(FINSH_PROMPT); - memset(shell->line, 0, sizeof(shell->line)); + rt_memset(shell->line, 0, sizeof(shell->line)); shell->line_curpos = shell->line_position = 0; continue; } diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index ef6baee8c5..4a44245b48 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -173,7 +173,7 @@ static size_t at_recvpkt_get(rt_slist_t *rlist, char *mem, size_t len) if (page_pos >= len - content_pos) { - memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, len - content_pos); + rt_memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, len - content_pos); pkt->bfsz_index += len - content_pos; if (pkt->bfsz_index == pkt->bfsz_totle) { @@ -184,7 +184,7 @@ static size_t at_recvpkt_get(rt_slist_t *rlist, char *mem, size_t len) } else { - memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, page_pos); + rt_memcpy((char *) mem + content_pos, pkt->buff + pkt->bfsz_index, page_pos); content_pos += page_pos; pkt->bfsz_index += page_pos; at_recvpkt_node_delete(rlist, node); @@ -1288,7 +1288,7 @@ int at_getaddrinfo(const char *nodename, const char *servname, { return EAI_MEMORY; } - memset(ai, 0, total_size); + rt_memset(ai, 0, total_size); /* cast through void* to get rid of alignment warnings */ sa = (struct sockaddr_storage *) (void *) ((uint8_t *) ai + sizeof(struct addrinfo)); struct sockaddr_in *sa4 = (struct sockaddr_in *) sa; @@ -1317,7 +1317,7 @@ int at_getaddrinfo(const char *nodename, const char *servname, { /* copy nodename to canonname if specified */ ai->ai_canonname = ((char *) ai + sizeof(struct addrinfo) + sizeof(struct sockaddr_storage)); - memcpy(ai->ai_canonname, nodename, namelen); + rt_memcpy(ai->ai_canonname, nodename, namelen); ai->ai_canonname[namelen] = 0; } ai->ai_addrlen = sizeof(struct sockaddr_storage); diff --git a/components/net/at/src/at_cli.c b/components/net/at/src/at_cli.c index d51358d863..5ff7880eee 100644 --- a/components/net/at/src/at_cli.c +++ b/components/net/at/src/at_cli.c @@ -123,14 +123,14 @@ static void server_cli_parser(void) device_bak = server->device; getchar_bak = server->get_char; - memset(endmark_back, 0x00, AT_END_MARK_LEN); - memcpy(endmark_back, server->end_mark, strlen(server->end_mark)); + rt_memset(endmark_back, 0x00, AT_END_MARK_LEN); + rt_memcpy(endmark_back, server->end_mark, strlen(server->end_mark)); /* setup server device as console device */ server->device = rt_console_get_device(); server->get_char = at_server_console_getchar; - memset(server->end_mark, 0x00, AT_END_MARK_LEN); + rt_memset(server->end_mark, 0x00, AT_END_MARK_LEN); server->end_mark[0] = '\r'; rt_hw_interrupt_enable(int_lvl); @@ -154,8 +154,8 @@ static void server_cli_parser(void) server->device = device_bak; server->get_char = getchar_bak; - memset(server->end_mark, 0x00, AT_END_MARK_LEN); - memcpy(server->end_mark, endmark_back, strlen(endmark_back)); + rt_memset(server->end_mark, 0x00, AT_END_MARK_LEN); + rt_memcpy(server->end_mark, endmark_back, strlen(endmark_back)); rt_hw_interrupt_enable(int_lvl); } diff --git a/components/net/at/src/at_server.c b/components/net/at/src/at_server.c index 1db26a260b..5d6a63fd98 100644 --- a/components/net/at/src/at_server.c +++ b/components/net/at/src/at_server.c @@ -406,7 +406,7 @@ static rt_err_t at_cmd_get_name(const char *cmd_buffer, char *cmd_name) || (*(cmd_buffer + i) >= AT_CMD_CHAR_0 && *(cmd_buffer + i) <= AT_CMD_CHAR_9)) { cmd_name_len = i; - memcpy(cmd_name, cmd_buffer, cmd_name_len); + rt_memcpy(cmd_name, cmd_buffer, cmd_name_len); *(cmd_name + cmd_name_len) = '\0'; return RT_EOK; @@ -508,7 +508,7 @@ static void server_parser(at_server_t server) } __retry: - memset(server->recv_buffer, 0x00, AT_SERVER_RECV_BUFF_LEN); + rt_memset(server->recv_buffer, 0x00, AT_SERVER_RECV_BUFF_LEN); server->cur_recv_len = 0; } } @@ -564,7 +564,7 @@ int at_server_init(void) at_server_local->echo_mode = 1; at_server_local->status = AT_STATUS_UNINITIALIZED; - memset(at_server_local->recv_buffer, 0x00, AT_SERVER_RECV_BUFF_LEN); + rt_memset(at_server_local->recv_buffer, 0x00, AT_SERVER_RECV_BUFF_LEN); at_server_local->cur_recv_len = 0; at_server_local->rx_notice = rt_sem_create("at_svr", 0, RT_IPC_FLAG_FIFO); @@ -600,7 +600,7 @@ int at_server_init(void) } at_server_local->get_char = at_server_getchar; - memcpy(at_server_local->end_mark, AT_CMD_END_MARK, sizeof(AT_CMD_END_MARK)); + rt_memcpy(at_server_local->end_mark, AT_CMD_END_MARK, sizeof(AT_CMD_END_MARK)); at_server_local->parser_entry = server_parser; at_server_local->parser = rt_thread_create("at_svr", diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 8c8ffd674a..21dc93100b 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -174,7 +174,7 @@ static void utest_run(const char *utest_name) tc_run_num = 0; if (tc_fail_list) { - memset(tc_fail_list, 0, TC_FAIL_LIST_SIZE); + rt_memset(tc_fail_list, 0, TC_FAIL_LIST_SIZE); } LOG_I("[==========] [ utest ] loop %d/%d", index + 1, tc_loop); diff --git a/components/utilities/zmodem/rz.c b/components/utilities/zmodem/rz.c index 1845fd24c2..224d8f95a8 100644 --- a/components/utilities/zmodem/rz.c +++ b/components/utilities/zmodem/rz.c @@ -44,7 +44,7 @@ void zr_start(char *path) rt_kprintf("zf: out of memory\r\n"); return; } - memset(zf, 0, sizeof(struct zfile)); + rt_memset(zf, 0, sizeof(struct zfile)); zf->fname = path; zf->fd = -1; res = zrec_files(zf); @@ -272,7 +272,7 @@ static rt_err_t zget_file_info(char *name, struct zfile *zf) rt_free(full_path); return -RT_ERROR; } - memset(full_path,0,len); + rt_memset(full_path,0,len); for (i=0,ptr=zf->fname;ifname = path; zf->fd = -1; res = zsend_files(zf);