- Explicitly initialize ch to 0
- Delete some spurious whitespace - Use calloc instead of malloc in the last test to ensure that sendspace is properly zero'ed out Differential Revision: https://reviews.freebsd.org/D689 (part of a larger diff) MFC after: 1 week Reviewed by: asomers, ngie Submitted by: markj Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
parent
7d6528d739
commit
f3b9984bce
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=292814
@ -1,5 +1,6 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2005 Robert N. M. Watson
|
* Copyright (c) 2005 Robert N. M. Watson
|
||||||
|
* Copyright (c) 2015 Mark Johnston
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -146,7 +147,7 @@ sendfd_payload(const char *test, int sockfd, int sendfd,
|
|||||||
static void
|
static void
|
||||||
sendfd(const char *test, int sockfd, int sendfd)
|
sendfd(const char *test, int sockfd, int sendfd)
|
||||||
{
|
{
|
||||||
char ch;
|
char ch = 0;
|
||||||
|
|
||||||
return (sendfd_payload(test, sockfd, sendfd, &ch, sizeof(ch)));
|
return (sendfd_payload(test, sockfd, sendfd, &ch, sizeof(ch)));
|
||||||
}
|
}
|
||||||
@ -199,7 +200,7 @@ recvfd_payload(const char *test, int sockfd, int *recvfd,
|
|||||||
static void
|
static void
|
||||||
recvfd(const char *test, int sockfd, int *recvfd)
|
recvfd(const char *test, int sockfd, int *recvfd)
|
||||||
{
|
{
|
||||||
char ch;
|
char ch = 0;
|
||||||
|
|
||||||
return (recvfd_payload(test, sockfd, recvfd, &ch, sizeof(ch)));
|
return (recvfd_payload(test, sockfd, recvfd, &ch, sizeof(ch)));
|
||||||
}
|
}
|
||||||
@ -369,8 +370,8 @@ main(void)
|
|||||||
err(-1, "%s: sysctlbyname(net.local.stream.sendspace)",
|
err(-1, "%s: sysctlbyname(net.local.stream.sendspace)",
|
||||||
test);
|
test);
|
||||||
|
|
||||||
if ((buf = malloc(sendspace)) == NULL)
|
if ((buf = calloc(1, sendspace)) == NULL)
|
||||||
err(-1, "%s: malloc", test);
|
err(-1, "%s: calloc", test);
|
||||||
|
|
||||||
domainsocketpair(test, fd);
|
domainsocketpair(test, fd);
|
||||||
if (setsockopt(fd[1], 0, LOCAL_CREDS, &on, sizeof(on)) < 0)
|
if (setsockopt(fd[1], 0, LOCAL_CREDS, &on, sizeof(on)) < 0)
|
||||||
@ -384,6 +385,6 @@ main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("%s passed\n", test);
|
printf("%s passed\n", test);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user