Skip to content

Commit

Permalink
Using POSIX-standard memory functions (bzero -> memset, bcopy -> memm…
Browse files Browse the repository at this point in the history
…ove)
  • Loading branch information
deRemo committed Oct 5, 2023
1 parent b2453bb commit c2588a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/dw_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ void hostport_parse_and_config(char* host_str, struct sockaddr_in* addr) {
inet_ntoa(*(struct in_addr *)e->h_addr));

// Build Internet address
bzero((char *) addr, sizeof(struct sockaddr_in));
memset((char *) addr, '\0', sizeof(struct sockaddr_in));
addr->sin_family = AF_INET;
bcopy((char *)e->h_addr, (char *) &addr->sin_addr.s_addr, e->h_length);
memmove((char *) &addr->sin_addr.s_addr, (char *)e->h_addr, e->h_length);
addr->sin_port = htons(port);

if (port_str)
Expand Down Expand Up @@ -412,9 +412,8 @@ void *thread_receiver(void *data) {
}
// make sure we reset the send timestamp and elapsed array to
// zeros for the next session
bzero(&usecs_send[thread_id][0], sizeof(usecs_send[thread_id]));
bzero(&usecs_elapsed[thread_id][0],
sizeof(usecs_elapsed[thread_id]));
memset(&usecs_send[thread_id][0], 0, sizeof(usecs_send[thread_id]));
memset(&usecs_elapsed[thread_id][0], 0, sizeof(usecs_elapsed[thread_id]));
}
cw_log("Joining sender thread\n");
pthread_join(sender[thread_id], NULL);
Expand Down
6 changes: 3 additions & 3 deletions src/dw_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ int start_forward(int conn_id, message_t *m, int cmd_id, int epollfd) {
cw_log("connecting to: %s:%d\n", inet_ntoa((struct in_addr) {m->cmds[cmd_id].u.fwd.fwd_host}),
ntohs(m->cmds[cmd_id].u.fwd.fwd_port));
struct sockaddr_in addr;
bzero((char *) &addr, sizeof(addr));
memset((char *) &addr, '\0', sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = m->cmds[cmd_id].u.fwd.fwd_host;
addr.sin_port = m->cmds[cmd_id].u.fwd.fwd_port;
Expand Down Expand Up @@ -736,7 +736,7 @@ int process_messages(int conn_id, int epollfd, thread_info_t* infos) {
"Moving %lu leftover bytes back to beginning of buf with "
"conn_id %d",
leftover, conn_id);
memmove(conns[conn_id].recv_buf, conns[conn_id].curr_proc_buf, leftover);
memmove(conns[conn_id].curr_proc_buf, conns[conn_id].recv_buf, leftover);
conns[conn_id].curr_recv_buf = conns[conn_id].recv_buf + leftover;
conns[conn_id].curr_recv_size = BUF_SIZE - leftover;
}
Expand Down Expand Up @@ -1016,7 +1016,7 @@ void* storage_worker(void* args) {
}

struct itimerspec ts;
bzero(&ts,sizeof(ts));
memset(&ts, 0, sizeof(ts));

struct timespec ts_template;
ts_template.tv_sec = infos->periodic_sync_msec / 1000;
Expand Down

0 comments on commit c2588a7

Please sign in to comment.