Skip to content

Commit 1483f6c

Browse files
authored
Merge pull request #102 from nirs/memset
Replace memset with designated initializer
2 parents 019843b + b620547 commit 1483f6c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

client/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ int main(int argc, char *argv[]) {
1515
}
1616
const char *socket_path = argv[1];
1717
int socket_fd = -1;
18-
struct sockaddr_un addr;
19-
memset(&addr, 0, sizeof(addr));
18+
struct sockaddr_un addr = {0};
2019
if ((socket_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
2120
perror("socket");
2221
exit(EXIT_FAILURE);

main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ static void stop(struct state *state, interface_ref iface) {
315315
static int socket_bindlisten(const char *socket_path,
316316
const char *socket_group) {
317317
int fd = -1;
318-
struct sockaddr_un addr;
319-
memset(&addr, 0, sizeof(addr));
318+
struct sockaddr_un addr = {0};
319+
320320
unlink(socket_path); /* avoid EADDRINUSE */
321321
if ((fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) {
322322
ERRORN("socket");
@@ -371,8 +371,7 @@ int main(int argc, char *argv[]) {
371371
int rc = 1, listen_fd = -1;
372372
__block interface_ref iface = NULL;
373373

374-
struct state state;
375-
memset(&state, 0, sizeof(state));
374+
struct state state = {0};
376375

377376
struct cli_options *cliopt = cli_options_parse(argc, argv);
378377
assert(cliopt != NULL);

0 commit comments

Comments
 (0)