Skip to content

Commit

Permalink
apps.vhost: suppress -Wstringop-truncation
Browse files Browse the repository at this point in the history
GCC 8 added a warning that affects a legitimate use case.
  • Loading branch information
alexandergall committed Mar 30, 2020
1 parent e2eecff commit 76c0c80
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/apps/vhost/vhost_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ int vhost_user_connect(const char *path)
}

un.sun_family = AF_UNIX;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(un.sun_path, path, sizeof(un.sun_path));

#pragma GCC diagnostic pop
if (connect(sock, (struct sockaddr *) &un, sizeof(un)) == -1) {
close(sock);
return -1;
Expand All @@ -54,7 +56,10 @@ int vhost_user_listen(const char *path)
}

un.sun_family = AF_UNIX;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(un.sun_path, path, sizeof(un.sun_path));
#pragma GCC diagnostic pop
unlink(un.sun_path);
if (bind(sock, (struct sockaddr *) &un, sizeof(un)) == -1) {
close(sock);
Expand Down

0 comments on commit 76c0c80

Please sign in to comment.