summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-01-04 07:11:15 +0000
committerngie <ngie@FreeBSD.org>2016-01-04 07:11:15 +0000
commita8eafa6419f0d0c9c836bb0806aeae7a2f74db9d (patch)
tree4b1fda2eca03743b6d2f38f44d8451eb10714352 /tools
parent803ee78f973b5e62ae764744369cf8e789dc28a7 (diff)
downloadFreeBSD-src-a8eafa6419f0d0c9c836bb0806aeae7a2f74db9d.zip
FreeBSD-src-a8eafa6419f0d0c9c836bb0806aeae7a2f74db9d.tar.gz
MFC r292814:
- 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 Submitted by: markj
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/sockets/unix_passfd/unix_passfd.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/regression/sockets/unix_passfd/unix_passfd.c b/tools/regression/sockets/unix_passfd/unix_passfd.c
index 07ef589..59c4c29 100644
--- a/tools/regression/sockets/unix_passfd/unix_passfd.c
+++ b/tools/regression/sockets/unix_passfd/unix_passfd.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2005 Robert N. M. Watson
+ * Copyright (c) 2015 Mark Johnston
* All rights reserved.
*
* 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
sendfd(const char *test, int sockfd, int sendfd)
{
- char ch;
+ char ch = 0;
return (sendfd_payload(test, sockfd, sendfd, &ch, sizeof(ch)));
}
@@ -199,7 +200,7 @@ recvfd_payload(const char *test, int sockfd, int *recvfd,
static void
recvfd(const char *test, int sockfd, int *recvfd)
{
- char ch;
+ char ch = 0;
return (recvfd_payload(test, sockfd, recvfd, &ch, sizeof(ch)));
}
@@ -369,8 +370,8 @@ main(void)
err(-1, "%s: sysctlbyname(net.local.stream.sendspace)",
test);
- if ((buf = malloc(sendspace)) == NULL)
- err(-1, "%s: malloc", test);
+ if ((buf = calloc(1, sendspace)) == NULL)
+ err(-1, "%s: calloc", test);
domainsocketpair(test, fd);
if (setsockopt(fd[1], 0, LOCAL_CREDS, &on, sizeof(on)) < 0)
@@ -384,6 +385,6 @@ main(void)
}
printf("%s passed\n", test);
-
+
return (0);
}
OpenPOWER on IntegriCloud