Skip to content

Commit

Permalink
Merge pull request #102 from nirs/memset
Browse files Browse the repository at this point in the history
Replace memset with designated initializer
  • Loading branch information
AkihiroSuda authored Dec 10, 2024
2 parents 019843b + b620547 commit 1483f6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ int main(int argc, char *argv[]) {
}
const char *socket_path = argv[1];
int socket_fd = -1;
struct sockaddr_un addr;
memset(&addr, 0, sizeof(addr));
struct sockaddr_un addr = {0};
if ((socket_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
perror("socket");
exit(EXIT_FAILURE);
Expand Down
7 changes: 3 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ static void stop(struct state *state, interface_ref iface) {
static int socket_bindlisten(const char *socket_path,
const char *socket_group) {
int fd = -1;
struct sockaddr_un addr;
memset(&addr, 0, sizeof(addr));
struct sockaddr_un addr = {0};

unlink(socket_path); /* avoid EADDRINUSE */
if ((fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
ERRORN("socket");
Expand Down Expand Up @@ -371,8 +371,7 @@ int main(int argc, char *argv[]) {
int rc = 1, listen_fd = -1;
__block interface_ref iface = NULL;

struct state state;
memset(&state, 0, sizeof(state));
struct state state = {0};

struct cli_options *cliopt = cli_options_parse(argc, argv);
assert(cliopt != NULL);
Expand Down

0 comments on commit 1483f6c

Please sign in to comment.