Resolve a warning in g++11

This commit is contained in:
Xie Han
2022-12-28 18:13:56 +08:00
parent 14e77ec840
commit 1e70d380c6
2 changed files with 2 additions and 2 deletions

View File

@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
struct sockaddr_un sun = { };
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, path, sizeof sun.sun_path);
strncpy(sun.sun_path, path, sizeof sun.sun_path - 1);
WFTutorialTask *task = MyFactory::create_tutorial_task(
(struct sockaddr *)&sun, sizeof sun,
0,

View File

@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
}
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, argv[1], sizeof sun.sun_path);
strncpy(sun.sun_path, argv[1], sizeof sun.sun_path - 1);
signal(SIGINT, sig_handler);