summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/jrand48.c5
-rw-r--r--lib/libc/gen/mrand48.c6
-rw-r--r--lib/libc/net/getaddrinfo.c12
3 files changed, 13 insertions, 10 deletions
diff --git a/lib/libc/gen/jrand48.c b/lib/libc/gen/jrand48.c
index 1707620..5aab1e1 100644
--- a/lib/libc/gen/jrand48.c
+++ b/lib/libc/gen/jrand48.c
@@ -14,11 +14,14 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <stdint.h>
+
#include "rand48.h"
long
jrand48(unsigned short xseed[3])
{
+
_dorand48(xseed);
- return ((long) xseed[2] << 16) + (long) xseed[1];
+ return ((int32_t)(((uint32_t)xseed[2] << 16) | (uint32_t)xseed[1]));
}
diff --git a/lib/libc/gen/mrand48.c b/lib/libc/gen/mrand48.c
index ef20fb87b..795a858 100644
--- a/lib/libc/gen/mrand48.c
+++ b/lib/libc/gen/mrand48.c
@@ -14,6 +14,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <stdint.h>
+
#include "rand48.h"
extern unsigned short _rand48_seed[3];
@@ -21,6 +23,8 @@ extern unsigned short _rand48_seed[3];
long
mrand48(void)
{
+
_dorand48(_rand48_seed);
- return ((long) _rand48_seed[2] << 16) + (long) _rand48_seed[1];
+ return ((int32_t)(((uint32_t)_rand48_seed[2] << 16) |
+ (uint32_t)_rand48_seed[1]));
}
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index ec22570..163241b 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -673,9 +673,8 @@ reorder(struct addrinfo *sentinel)
return(n);
/* allocate a temporary array for sort and initialization of it. */
- if ((aio = malloc(sizeof(*aio) * n)) == NULL)
+ if ((aio = calloc(n, sizeof(*aio))) == NULL)
return(n); /* give up reordering */
- memset(aio, 0, sizeof(*aio) * n);
/* retrieve address selection policy from the kernel */
TAILQ_INIT(&policyhead);
@@ -1454,9 +1453,8 @@ copy_ai(const struct addrinfo *pai)
size_t l;
l = sizeof(*ai) + pai->ai_addrlen;
- if ((ai = (struct addrinfo *)malloc(l)) == NULL)
+ if ((ai = calloc(1, l)) == NULL)
return NULL;
- memset(ai, 0, l);
memcpy(ai, pai, sizeof(*ai));
ai->ai_addr = (struct sockaddr *)(void *)(ai + 1);
memcpy(ai->ai_addr, pai->ai_addr, pai->ai_addrlen);
@@ -1876,8 +1874,7 @@ addrinfo_unmarshal_func(char *buffer, size_t buffer_size, void *retval,
size = new_ai.ai_addrlen + sizeof(struct addrinfo) +
_ALIGNBYTES;
- sentinel = (struct addrinfo *)malloc(size);
- memset(sentinel, 0, size);
+ sentinel = calloc(1, size);
memcpy(sentinel, &new_ai, sizeof(struct addrinfo));
sentinel->ai_addr = (struct sockaddr *)_ALIGN((char *)sentinel +
@@ -1890,8 +1887,7 @@ addrinfo_unmarshal_func(char *buffer, size_t buffer_size, void *retval,
memcpy(&size, p, sizeof(size_t));
p += sizeof(size_t);
- sentinel->ai_canonname = (char *)malloc(size + 1);
- memset(sentinel->ai_canonname, 0, size + 1);
+ sentinel->ai_canonname = calloc(1, size + 1);
memcpy(sentinel->ai_canonname, p, size);
p += size;
OpenPOWER on IntegriCloud