Skip to content
Snippets Groups Projects
Commit 99456e07 authored by Nadav Har'El's avatar Nadav Har'El Committed by Pekka Enberg
Browse files

Some small fixes to tst-pipe.cc


tst-pipe.cc read a buffer after freeing it, which could have theoretically
caused segfaults (it didn't in practice, but better fix this oversight).

Also, it forgot to return a return code, so it doesn't play nicely in
a test framework like testrunner.so. I'm surprised the C++ compiler wasn't
bothered by an int main() not returning an int.

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 7a986ba7
No related branches found
No related tags found
No related merge requests found
...@@ -330,7 +330,9 @@ int main(int ac, char** av) ...@@ -330,7 +330,9 @@ int main(int ac, char** av)
report(r==1 && poller.revents == POLLOUT, "empty pipe is ready for write"); report(r==1 && poller.revents == POLLOUT, "empty pipe is ready for write");
r = fcntl(s[1], F_SETFL, O_NONBLOCK); r = fcntl(s[1], F_SETFL, O_NONBLOCK);
report(r == 0, "set write side to nonblocking"); report(r == 0, "set write side to nonblocking");
buf1 = (char*) calloc(1, TSTBUFSIZE);
r = write(s[1], buf1, TSTBUFSIZE); r = write(s[1], buf1, TSTBUFSIZE);
free(buf1);
report(r > 0, "large write to fill pipe"); report(r > 0, "large write to fill pipe");
r = fcntl(s[1], F_SETFL, 0); r = fcntl(s[1], F_SETFL, 0);
report(r == 0, "set write side to blocking"); report(r == 0, "set write side to blocking");
...@@ -364,6 +366,7 @@ int main(int ac, char** av) ...@@ -364,6 +366,7 @@ int main(int ac, char** av)
debug("SUMMARY: %d tests, %d failures\n", tests, fails); debug("SUMMARY: %d tests, %d failures\n", tests, fails);
return fails == 0 ? 0 : 1;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment