2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

apply the modified style

This commit is contained in:
Evan Hunt
2020-02-13 14:44:37 -08:00
parent 0255a97473
commit e851ed0bb5
669 changed files with 35995 additions and 42219 deletions

View File

@@ -27,12 +27,11 @@
#include <sys/stat.h>
#include <sys/types.h>
#define ISC_DIR_MAGIC ISC_MAGIC('D', 'I', 'R', '*')
#define ISC_DIR_MAGIC ISC_MAGIC('D', 'I', 'R', '*')
#define VALID_DIR(dir) ISC_MAGIC_VALID(dir, ISC_DIR_MAGIC)
void
isc_dir_init(isc_dir_t *dir)
{
isc_dir_init(isc_dir_t *dir) {
REQUIRE(dir != NULL);
dir->entry.name[0] = '\0';
@@ -48,9 +47,8 @@ isc_dir_init(isc_dir_t *dir)
* NULL will be returned.
*/
isc_result_t
isc_dir_open(isc_dir_t *dir, const char *dirname)
{
char * p;
isc_dir_open(isc_dir_t *dir, const char *dirname) {
char *p;
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(VALID_DIR(dir));
@@ -96,8 +94,7 @@ isc_dir_open(isc_dir_t *dir, const char *dirname)
* the dir stream and reads the first file in one operation.
*/
isc_result_t
isc_dir_read(isc_dir_t *dir)
{
isc_dir_read(isc_dir_t *dir) {
struct dirent *entry;
REQUIRE(VALID_DIR(dir) && dir->handle != NULL);
@@ -132,8 +129,7 @@ isc_dir_read(isc_dir_t *dir)
* \brief Close directory stream.
*/
void
isc_dir_close(isc_dir_t *dir)
{
isc_dir_close(isc_dir_t *dir) {
REQUIRE(VALID_DIR(dir) && dir->handle != NULL);
(void)closedir(dir->handle);
@@ -144,8 +140,7 @@ isc_dir_close(isc_dir_t *dir)
* \brief Reposition directory stream at start.
*/
isc_result_t
isc_dir_reset(isc_dir_t *dir)
{
isc_dir_reset(isc_dir_t *dir) {
REQUIRE(VALID_DIR(dir) && dir->handle != NULL);
rewinddir(dir->handle);
@@ -154,8 +149,7 @@ isc_dir_reset(isc_dir_t *dir)
}
isc_result_t
isc_dir_chdir(const char *dirname)
{
isc_dir_chdir(const char *dirname) {
/*!
* \brief Change the current directory to 'dirname'.
*/
@@ -170,8 +164,7 @@ isc_dir_chdir(const char *dirname)
}
isc_result_t
isc_dir_chroot(const char *dirname)
{
isc_dir_chroot(const char *dirname) {
#ifdef HAVE_CHROOT
void *tmp;
#endif /* ifdef HAVE_CHROOT */
@@ -201,13 +194,12 @@ isc_dir_chroot(const char *dirname)
}
isc_result_t
isc_dir_createunique(char *templet)
{
isc_dir_createunique(char *templet) {
isc_result_t result;
char * x;
char * p;
int i;
int pid;
char *x;
char *p;
int i;
int pid;
REQUIRE(templet != NULL);
@@ -221,7 +213,8 @@ isc_dir_createunique(char *templet)
* Replace trailing Xs with the process-id, zero-filled.
*/
for (x = templet + strlen(templet) - 1; *x == 'X' && x >= templet;
x--, pid /= 10) {
x--, pid /= 10)
{
*x = pid % 10 + '0';
}

View File

@@ -17,7 +17,6 @@
#include "errno2result.h"
isc_result_t
isc_errno_toresult(int err)
{
isc_errno_toresult(int err) {
return (isc___errno2result(err, false, 0, 0));
}

View File

@@ -29,8 +29,7 @@
*/
isc_result_t
isc___errno2result(int posixerrno, bool dolog, const char *file,
unsigned int line)
{
unsigned int line) {
char strbuf[ISC_STRERRORSIZE];
switch (posixerrno) {

View File

@@ -79,8 +79,7 @@
* annoying MP issues. BTW, Win32 has stat().
*/
static isc_result_t
file_stats(const char *file, struct stat *stats)
{
file_stats(const char *file, struct stat *stats) {
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(file != NULL);
@@ -94,8 +93,7 @@ file_stats(const char *file, struct stat *stats)
}
static isc_result_t
fd_stats(int fd, struct stat *stats)
{
fd_stats(int fd, struct stat *stats) {
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(stats != NULL);
@@ -108,10 +106,9 @@ fd_stats(int fd, struct stat *stats)
}
isc_result_t
isc_file_getsizefd(int fd, off_t *size)
{
isc_file_getsizefd(int fd, off_t *size) {
isc_result_t result;
struct stat stats;
struct stat stats;
REQUIRE(size != NULL);
@@ -125,10 +122,9 @@ isc_file_getsizefd(int fd, off_t *size)
}
isc_result_t
isc_file_mode(const char *file, mode_t *modep)
{
isc_file_mode(const char *file, mode_t *modep) {
isc_result_t result;
struct stat stats;
struct stat stats;
REQUIRE(modep != NULL);
@@ -141,10 +137,9 @@ isc_file_mode(const char *file, mode_t *modep)
}
isc_result_t
isc_file_getmodtime(const char *file, isc_time_t *modtime)
{
isc_file_getmodtime(const char *file, isc_time_t *modtime) {
isc_result_t result;
struct stat stats;
struct stat stats;
REQUIRE(file != NULL);
REQUIRE(modtime != NULL);
@@ -163,10 +158,9 @@ isc_file_getmodtime(const char *file, isc_time_t *modtime)
}
isc_result_t
isc_file_getsize(const char *file, off_t *size)
{
isc_file_getsize(const char *file, off_t *size) {
isc_result_t result;
struct stat stats;
struct stat stats;
REQUIRE(file != NULL);
REQUIRE(size != NULL);
@@ -181,8 +175,7 @@ isc_file_getsize(const char *file, off_t *size)
}
isc_result_t
isc_file_settime(const char *file, isc_time_t *when)
{
isc_file_settime(const char *file, isc_time_t *when) {
struct timeval times[2];
REQUIRE(file != NULL && when != NULL);
@@ -225,15 +218,13 @@ isc_file_settime(const char *file, isc_time_t *when)
#define TEMPLATE "tmp-XXXXXXXXXX" /*%< 14 characters. */
isc_result_t
isc_file_mktemplate(const char *path, char *buf, size_t buflen)
{
isc_file_mktemplate(const char *path, char *buf, size_t buflen) {
return (isc_file_template(path, TEMPLATE, buf, buflen));
}
isc_result_t
isc_file_template(const char *path, const char *templet, char *buf,
size_t buflen)
{
size_t buflen) {
const char *s;
REQUIRE(templet != NULL);
@@ -274,8 +265,7 @@ static const char alphnum[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv"
"wxyz0123456789";
isc_result_t
isc_file_renameunique(const char *file, char *templet)
{
isc_file_renameunique(const char *file, char *templet) {
char *x;
char *cp;
@@ -322,27 +312,24 @@ isc_file_renameunique(const char *file, char *templet)
}
isc_result_t
isc_file_openunique(char *templet, FILE **fp)
{
isc_file_openunique(char *templet, FILE **fp) {
int mode = S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
return (isc_file_openuniquemode(templet, mode, fp));
}
isc_result_t
isc_file_openuniqueprivate(char *templet, FILE **fp)
{
isc_file_openuniqueprivate(char *templet, FILE **fp) {
int mode = S_IWUSR | S_IRUSR;
return (isc_file_openuniquemode(templet, mode, fp));
}
isc_result_t
isc_file_openuniquemode(char *templet, int mode, FILE **fp)
{
int fd;
FILE * f;
isc_file_openuniquemode(char *templet, int mode, FILE **fp) {
int fd;
FILE *f;
isc_result_t result = ISC_R_SUCCESS;
char * x;
char * cp;
char *x;
char *cp;
REQUIRE(templet != NULL);
REQUIRE(fp != NULL && *fp == NULL);
@@ -396,28 +383,24 @@ isc_file_openuniquemode(char *templet, int mode, FILE **fp)
}
isc_result_t
isc_file_bopenunique(char *templet, FILE **fp)
{
isc_file_bopenunique(char *templet, FILE **fp) {
int mode = S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
return (isc_file_openuniquemode(templet, mode, fp));
}
isc_result_t
isc_file_bopenuniqueprivate(char *templet, FILE **fp)
{
isc_file_bopenuniqueprivate(char *templet, FILE **fp) {
int mode = S_IWUSR | S_IRUSR;
return (isc_file_openuniquemode(templet, mode, fp));
}
isc_result_t
isc_file_bopenuniquemode(char *templet, int mode, FILE **fp)
{
isc_file_bopenuniquemode(char *templet, int mode, FILE **fp) {
return (isc_file_openuniquemode(templet, mode, fp));
}
isc_result_t
isc_file_remove(const char *filename)
{
isc_file_remove(const char *filename) {
int r;
REQUIRE(filename != NULL);
@@ -431,8 +414,7 @@ isc_file_remove(const char *filename)
}
isc_result_t
isc_file_rename(const char *oldname, const char *newname)
{
isc_file_rename(const char *oldname, const char *newname) {
int r;
REQUIRE(oldname != NULL);
@@ -447,8 +429,7 @@ isc_file_rename(const char *oldname, const char *newname)
}
bool
isc_file_exists(const char *pathname)
{
isc_file_exists(const char *pathname) {
struct stat stats;
REQUIRE(pathname != NULL);
@@ -457,8 +438,7 @@ isc_file_exists(const char *pathname)
}
isc_result_t
isc_file_isplainfile(const char *filename)
{
isc_file_isplainfile(const char *filename) {
/*
* This function returns success if filename is a plain file.
*/
@@ -477,8 +457,7 @@ isc_file_isplainfile(const char *filename)
}
isc_result_t
isc_file_isplainfilefd(int fd)
{
isc_file_isplainfilefd(int fd) {
/*
* This function returns success if filename is a plain file.
*/
@@ -497,8 +476,7 @@ isc_file_isplainfilefd(int fd)
}
isc_result_t
isc_file_isdirectory(const char *filename)
{
isc_file_isdirectory(const char *filename) {
/*
* This function returns success if filename exists and is a
* directory.
@@ -518,22 +496,19 @@ isc_file_isdirectory(const char *filename)
}
bool
isc_file_isabsolute(const char *filename)
{
isc_file_isabsolute(const char *filename) {
REQUIRE(filename != NULL);
return (filename[0] == '/');
}
bool
isc_file_iscurrentdir(const char *filename)
{
isc_file_iscurrentdir(const char *filename) {
REQUIRE(filename != NULL);
return (filename[0] == '.' && filename[1] == '\0');
}
bool
isc_file_ischdiridempotent(const char *filename)
{
isc_file_ischdiridempotent(const char *filename) {
REQUIRE(filename != NULL);
if (isc_file_isabsolute(filename)) {
return (true);
@@ -545,8 +520,7 @@ isc_file_ischdiridempotent(const char *filename)
}
const char *
isc_file_basename(const char *filename)
{
isc_file_basename(const char *filename) {
const char *s;
REQUIRE(filename != NULL);
@@ -560,10 +534,9 @@ isc_file_basename(const char *filename)
}
isc_result_t
isc_file_progname(const char *filename, char *buf, size_t buflen)
{
isc_file_progname(const char *filename, char *buf, size_t buflen) {
const char *base;
size_t len;
size_t len;
REQUIRE(filename != NULL);
REQUIRE(buf != NULL);
@@ -586,9 +559,8 @@ isc_file_progname(const char *filename, char *buf, size_t buflen)
* concatenated with a relative pathname to make a valid pathname string.
*/
static isc_result_t
dir_current(char *dirname, size_t length)
{
char * cwd;
dir_current(char *dirname, size_t length) {
char *cwd;
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(dirname != NULL);
@@ -614,8 +586,7 @@ dir_current(char *dirname, size_t length)
}
isc_result_t
isc_file_absolutepath(const char *filename, char *path, size_t pathlen)
{
isc_file_absolutepath(const char *filename, char *path, size_t pathlen) {
isc_result_t result;
result = dir_current(path, pathlen);
if (result != ISC_R_SUCCESS) {
@@ -629,8 +600,7 @@ isc_file_absolutepath(const char *filename, char *path, size_t pathlen)
}
isc_result_t
isc_file_truncate(const char *filename, isc_offset_t size)
{
isc_file_truncate(const char *filename, isc_offset_t size) {
isc_result_t result = ISC_R_SUCCESS;
if (truncate(filename, size) < 0) {
@@ -640,13 +610,12 @@ isc_file_truncate(const char *filename, isc_offset_t size)
}
isc_result_t
isc_file_safecreate(const char *filename, FILE **fp)
{
isc_file_safecreate(const char *filename, FILE **fp) {
isc_result_t result;
int flags;
struct stat sb;
FILE * f;
int fd;
int flags;
struct stat sb;
FILE *f;
int fd;
REQUIRE(filename != NULL);
REQUIRE(fp != NULL && *fp == NULL);
@@ -681,9 +650,8 @@ isc_file_safecreate(const char *filename, FILE **fp)
isc_result_t
isc_file_splitpath(isc_mem_t *mctx, const char *path, char **dirname,
char const **bname)
{
char * dir;
char const **bname) {
char *dir;
const char *file, *slash;
if (path == NULL) {
@@ -720,50 +688,49 @@ isc_file_splitpath(isc_mem_t *mctx, const char *path, char **dirname,
}
void *
isc_file_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
{
isc_file_mmap(void *addr, size_t len, int prot, int flags, int fd,
off_t offset) {
#ifdef HAVE_MMAP
return (mmap(addr, len, prot, flags, fd, offset));
#else /* ifdef HAVE_MMAP */
void * buf;
ssize_t ret;
off_t end;
void *buf;
ssize_t ret;
off_t end;
UNUSED(addr);
UNUSED(prot);
UNUSED(flags);
UNUSED(addr);
UNUSED(prot);
UNUSED(flags);
end = lseek(fd, 0, SEEK_END);
lseek(fd, offset, SEEK_SET);
if (end - offset < (off_t)len) {
len = end - offset;
}
end = lseek(fd, 0, SEEK_END);
lseek(fd, offset, SEEK_SET);
if (end - offset < (off_t)len) {
len = end - offset;
}
buf = malloc(len);
if (buf == NULL) {
return (NULL);
}
buf = malloc(len);
if (buf == NULL) {
return (NULL);
}
ret = read(fd, buf, len);
if (ret != (ssize_t)len) {
free(buf);
buf = NULL;
}
ret = read(fd, buf, len);
if (ret != (ssize_t)len) {
free(buf);
buf = NULL;
}
return (buf);
return (buf);
#endif /* ifdef HAVE_MMAP */
}
int
isc_file_munmap(void *addr, size_t len)
{
isc_file_munmap(void *addr, size_t len) {
#ifdef HAVE_MMAP
return (munmap(addr, len));
#else /* ifdef HAVE_MMAP */
UNUSED(len);
UNUSED(len);
free(addr);
return (0);
free(addr);
return (0);
#endif /* ifdef HAVE_MMAP */
}
@@ -771,10 +738,9 @@ isc_file_munmap(void *addr, size_t len)
static isc_result_t
digest2hex(unsigned char *digest, unsigned int digestlen, char *hash,
size_t hashlen)
{
size_t hashlen) {
unsigned int i;
int ret;
int ret;
for (i = 0; i < digestlen; i++) {
size_t left = hashlen - i * 2;
ret = snprintf(hash + i * 2, left, "%02x", digest[i]);
@@ -787,14 +753,13 @@ digest2hex(unsigned char *digest, unsigned int digestlen, char *hash,
isc_result_t
isc_file_sanitize(const char *dir, const char *base, const char *ext,
char *path, size_t length)
{
char buf[PATH_MAX];
char *path, size_t length) {
char buf[PATH_MAX];
unsigned char digest[ISC_MAX_MD_SIZE];
unsigned int digestlen;
char hash[ISC_MAX_MD_SIZE * 2 + 1];
size_t l = 0;
isc_result_t err;
unsigned int digestlen;
char hash[ISC_MAX_MD_SIZE * 2 + 1];
size_t l = 0;
isc_result_t err;
REQUIRE(base != NULL);
REQUIRE(path != NULL);
@@ -868,7 +833,6 @@ isc_file_sanitize(const char *dir, const char *base, const char *ext,
}
bool
isc_file_isdirwritable(const char *path)
{
isc_file_isdirwritable(const char *path) {
return (access(path, W_OK | X_OK) == 0);
}

View File

@@ -24,13 +24,12 @@
#include "../fsaccess.c"
isc_result_t
isc_fsaccess_set(const char *path, isc_fsaccess_t access)
{
struct stat statb;
mode_t mode;
bool is_dir = false;
isc_fsaccess_set(const char *path, isc_fsaccess_t access) {
struct stat statb;
mode_t mode;
bool is_dir = false;
isc_fsaccess_t bits;
isc_result_t result;
isc_result_t result;
if (stat(path, &statb) != 0) {
return (isc__errno2result(errno));

View File

@@ -30,27 +30,26 @@ static bool seenv6 = false;
/*% Iterator structure */
struct isc_interfaceiter {
unsigned int magic; /*%< Magic number. */
isc_mem_t * mctx;
void * buf; /*%< (unused) */
unsigned int bufsize; /*%< (always 0) */
unsigned int magic; /*%< Magic number. */
isc_mem_t *mctx;
void *buf; /*%< (unused) */
unsigned int bufsize; /*%< (always 0) */
struct ifaddrs *ifaddrs; /*%< List of ifaddrs */
struct ifaddrs *pos; /*%< Ptr to current ifaddr */
isc_interface_t current; /*%< Current interface data. */
isc_result_t result; /*%< Last result code. */
isc_result_t result; /*%< Last result code. */
#ifdef __linux
FILE * proc;
char entry[ISC_IF_INET6_SZ];
FILE *proc;
char entry[ISC_IF_INET6_SZ];
isc_result_t valid;
#endif /* ifdef __linux */
};
isc_result_t
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp)
{
isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
isc_interfaceiter_t *iter;
isc_result_t result;
char strbuf[ISC_STRERRORSIZE];
isc_result_t result;
char strbuf[ISC_STRERRORSIZE];
REQUIRE(mctx != NULL);
REQUIRE(iterp != NULL);
@@ -116,11 +115,10 @@ failure:
*/
static isc_result_t
internal_current(isc_interfaceiter_t *iter)
{
internal_current(isc_interfaceiter_t *iter) {
struct ifaddrs *ifa;
int family;
unsigned int namelen;
int family;
unsigned int namelen;
REQUIRE(VALID_IFITER(iter));
@@ -184,7 +182,8 @@ internal_current(isc_interfaceiter_t *iter)
}
if (ifa->ifa_dstaddr != NULL &&
(iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) {
(iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0)
{
get_addr(family, &iter->current.dstaddress, ifa->ifa_dstaddr,
ifa->ifa_name);
}
@@ -200,8 +199,7 @@ internal_current(isc_interfaceiter_t *iter)
* interfaces, otherwise ISC_R_SUCCESS.
*/
static isc_result_t
internal_next(isc_interfaceiter_t *iter)
{
internal_next(isc_interfaceiter_t *iter) {
if (iter->pos != NULL) {
iter->pos = iter->pos->ifa_next;
}
@@ -218,8 +216,7 @@ internal_next(isc_interfaceiter_t *iter)
}
static void
internal_destroy(isc_interfaceiter_t *iter)
{
internal_destroy(isc_interfaceiter_t *iter) {
#ifdef __linux
if (iter->proc != NULL) {
fclose(iter->proc);
@@ -233,8 +230,7 @@ internal_destroy(isc_interfaceiter_t *iter)
}
static void
internal_first(isc_interfaceiter_t *iter)
{
internal_first(isc_interfaceiter_t *iter) {
#ifdef __linux
linux_if_inet6_first(iter);
#endif /* ifdef __linux */

View File

@@ -274,11 +274,11 @@ isc_net_probeunix(void);
#define ISC_NET_DSCPRECVV4 0x01 /* Can receive sent DSCP value IPv4 */
#define ISC_NET_DSCPRECVV6 0x02 /* Can receive sent DSCP value IPv6 */
#define ISC_NET_DSCPSETV4 0x04 /* Can set DSCP on socket IPv4 */
#define ISC_NET_DSCPSETV6 0x08 /* Can set DSCP on socket IPv6 */
#define ISC_NET_DSCPPKTV4 0x10 /* Can set DSCP on per packet IPv4 */
#define ISC_NET_DSCPPKTV6 0x20 /* Can set DSCP on per packet IPv6 */
#define ISC_NET_DSCPALL 0x3f /* All valid flags */
#define ISC_NET_DSCPSETV4 0x04 /* Can set DSCP on socket IPv4 */
#define ISC_NET_DSCPSETV6 0x08 /* Can set DSCP on socket IPv6 */
#define ISC_NET_DSCPPKTV4 0x10 /* Can set DSCP on per packet IPv4 */
#define ISC_NET_DSCPPKTV6 0x20 /* Can set DSCP on per packet IPv6 */
#define ISC_NET_DSCPALL 0x3f /* All valid flags */
unsigned int
isc_net_probedscp(void);

View File

@@ -82,7 +82,7 @@ typedef bool atomic_bool;
typedef uint_fast64_t atomic_uintptr_t;
#if defined(__CLANG_ATOMICS) /* __c11_atomic builtins */
#define atomic_init(obj, desired) __c11_atomic_init(obj, desired)
#define atomic_init(obj, desired) __c11_atomic_init(obj, desired)
#define atomic_load_explicit(obj, order) __c11_atomic_load(obj, order)
#define atomic_store_explicit(obj, desired, order) \
__c11_atomic_store(obj, desired, order)
@@ -105,7 +105,7 @@ typedef uint_fast64_t atomic_uintptr_t;
#define atomic_exchange_explicit(obj, desired, order) \
__c11_atomic_exchange_explicit(obj, expected, order)
#elif defined(__GNUC_ATOMICS) /* __atomic builtins */
#define atomic_init(obj, desired) (*obj = desired)
#define atomic_init(obj, desired) (*obj = desired)
#define atomic_load_explicit(obj, order) __atomic_load_n(obj, order)
#define atomic_store_explicit(obj, desired, order) \
__atomic_store_n(obj, desired, order)
@@ -126,7 +126,7 @@ typedef uint_fast64_t atomic_uintptr_t;
#define atomic_exchange_explicit(obj, desired, order) \
__atomic_exchange_n(obj, desired, order)
#else /* __sync builtins */
#define atomic_init(obj, desired) (*obj = desired)
#define atomic_init(obj, desired) (*obj = desired)
#define atomic_load_explicit(obj, order) __sync_fetch_and_add(obj, 0)
#define atomic_store_explicit(obj, desired, order) \
do { \

View File

@@ -54,8 +54,7 @@
static void
get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
char *ifname)
{
char *ifname) {
struct sockaddr_in6 *sa6;
#if !defined(HAVE_IF_NAMETOINDEX)
@@ -135,20 +134,16 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
#define ISC_IF_INET6_SZ \
sizeof("00000000000000000000000000000001 01 80 10 80 " \
"XXXXXXloXXXXXXXX\n")
static isc_result_t
linux_if_inet6_next(isc_interfaceiter_t *);
static isc_result_t
linux_if_inet6_current(isc_interfaceiter_t *);
static void
linux_if_inet6_first(isc_interfaceiter_t *iter);
static isc_result_t linux_if_inet6_next(isc_interfaceiter_t *);
static isc_result_t linux_if_inet6_current(isc_interfaceiter_t *);
static void linux_if_inet6_first(isc_interfaceiter_t *iter);
#endif /* ifdef __linux */
#include "ifiter_getifaddrs.c"
#ifdef __linux
static void
linux_if_inet6_first(isc_interfaceiter_t *iter)
{
linux_if_inet6_first(isc_interfaceiter_t *iter) {
if (iter->proc != NULL) {
rewind(iter->proc);
(void)linux_if_inet6_next(iter);
@@ -158,10 +153,10 @@ linux_if_inet6_first(isc_interfaceiter_t *iter)
}
static isc_result_t
linux_if_inet6_next(isc_interfaceiter_t *iter)
{
linux_if_inet6_next(isc_interfaceiter_t *iter) {
if (iter->proc != NULL &&
fgets(iter->entry, sizeof(iter->entry), iter->proc) != NULL) {
fgets(iter->entry, sizeof(iter->entry), iter->proc) != NULL)
{
iter->valid = ISC_R_SUCCESS;
} else {
iter->valid = ISC_R_NOMORE;
@@ -170,14 +165,13 @@ linux_if_inet6_next(isc_interfaceiter_t *iter)
}
static isc_result_t
linux_if_inet6_current(isc_interfaceiter_t *iter)
{
char address[33];
char name[IF_NAMESIZE + 1];
linux_if_inet6_current(isc_interfaceiter_t *iter) {
char address[33];
char name[IF_NAMESIZE + 1];
struct in6_addr addr6;
unsigned int ifindex, prefix, flag3, flag4;
int res;
unsigned int i;
unsigned int ifindex, prefix, flag3, flag4;
int res;
unsigned int i;
if (iter->valid != ISC_R_SUCCESS) {
return (iter->valid);
@@ -205,7 +199,7 @@ linux_if_inet6_current(isc_interfaceiter_t *iter)
return (ISC_R_FAILURE);
}
for (i = 0; i < 16; i++) {
unsigned char byte;
unsigned char byte;
static const char hex[] = "0123456789abcdef";
byte = ((strchr(hex, address[i * 2]) - hex) << 4) |
(strchr(hex, address[i * 2 + 1]) - hex);
@@ -237,16 +231,14 @@ linux_if_inet6_current(isc_interfaceiter_t *iter)
*/
isc_result_t
isc_interfaceiter_current(isc_interfaceiter_t *iter, isc_interface_t *ifdata)
{
isc_interfaceiter_current(isc_interfaceiter_t *iter, isc_interface_t *ifdata) {
REQUIRE(iter->result == ISC_R_SUCCESS);
memmove(ifdata, &iter->current, sizeof(*ifdata));
return (ISC_R_SUCCESS);
}
isc_result_t
isc_interfaceiter_first(isc_interfaceiter_t *iter)
{
isc_interfaceiter_first(isc_interfaceiter_t *iter) {
isc_result_t result;
REQUIRE(VALID_IFITER(iter));
@@ -267,8 +259,7 @@ isc_interfaceiter_first(isc_interfaceiter_t *iter)
}
isc_result_t
isc_interfaceiter_next(isc_interfaceiter_t *iter)
{
isc_interfaceiter_next(isc_interfaceiter_t *iter) {
isc_result_t result;
REQUIRE(VALID_IFITER(iter));
@@ -289,8 +280,7 @@ isc_interfaceiter_next(isc_interfaceiter_t *iter)
}
void
isc_interfaceiter_destroy(isc_interfaceiter_t **iterp)
{
isc_interfaceiter_destroy(isc_interfaceiter_t **iterp) {
isc_interfaceiter_t *iter;
REQUIRE(iterp != NULL);
iter = *iterp;

View File

@@ -18,8 +18,7 @@
#endif /* if defined(HAVE_SYS_SYSCTL_H) && !defined(__linux__) */
uint64_t
isc_meminfo_totalphys(void)
{
isc_meminfo_totalphys(void) {
#if defined(CTL_HW) && (defined(HW_PHYSMEM64) || defined(HW_MEMSIZE))
int mib[2];
mib[0] = CTL_HW;
@@ -29,7 +28,7 @@ isc_meminfo_totalphys(void)
mib[1] = HW_PHYSMEM64;
#endif /* if defined(HW_MEMSIZE) */
uint64_t size = 0;
size_t len = sizeof(size);
size_t len = sizeof(size);
if (sysctl(mib, 2, &size, &len, NULL, 0) == 0) {
return (size);
}

View File

@@ -61,18 +61,18 @@
*/
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
#define USE_SYSCTL_PORTRANGE
#define SYSCTL_V4PORTRANGE_LOW "net.inet.ip.portrange.hifirst"
#define SYSCTL_V4PORTRANGE_LOW "net.inet.ip.portrange.hifirst"
#define SYSCTL_V4PORTRANGE_HIGH "net.inet.ip.portrange.hilast"
#define SYSCTL_V6PORTRANGE_LOW "net.inet.ip.portrange.hifirst"
#define SYSCTL_V6PORTRANGE_LOW "net.inet.ip.portrange.hifirst"
#define SYSCTL_V6PORTRANGE_HIGH "net.inet.ip.portrange.hilast"
#endif /* if defined(__FreeBSD__) || defined(__APPLE__) || \
* defined(__DragonFly__) */
#ifdef __NetBSD__
#define USE_SYSCTL_PORTRANGE
#define SYSCTL_V4PORTRANGE_LOW "net.inet.ip.anonportmin"
#define SYSCTL_V4PORTRANGE_LOW "net.inet.ip.anonportmin"
#define SYSCTL_V4PORTRANGE_HIGH "net.inet.ip.anonportmax"
#define SYSCTL_V6PORTRANGE_LOW "net.inet6.ip6.anonportmin"
#define SYSCTL_V6PORTRANGE_LOW "net.inet6.ip6.anonportmin"
#define SYSCTL_V6PORTRANGE_HIGH "net.inet6.ip6.anonportmax"
#endif /* ifdef __NetBSD__ */
@@ -89,7 +89,7 @@
CTL_NET, PF_INET, IPPROTO_IP, IPCTL_IPPORT_HILASTAUTO \
}
/* Same for IPv6 */
#define SYSCTL_V6PORTRANGE_LOW SYSCTL_V4PORTRANGE_LOW
#define SYSCTL_V6PORTRANGE_LOW SYSCTL_V4PORTRANGE_LOW
#define SYSCTL_V6PORTRANGE_HIGH SYSCTL_V4PORTRANGE_HIGH
#endif /* ifdef __OpenBSD__ */
@@ -119,11 +119,10 @@ static isc_result_t ipv6pktinfo_result = ISC_R_NOTFOUND;
static unsigned int dscp_result = 0;
static isc_result_t
try_proto(int domain)
{
int s;
try_proto(int domain) {
int s;
isc_result_t result = ISC_R_SUCCESS;
char strbuf[ISC_STRERRORSIZE];
char strbuf[ISC_STRERRORSIZE];
s = socket(domain, SOCK_STREAM, 0);
if (s == -1) {
@@ -151,14 +150,14 @@ try_proto(int domain)
if (domain == PF_INET6) {
struct sockaddr_in6 sin6;
unsigned int len;
unsigned int len;
/*
* Check to see if IPv6 is broken, as is common on Linux.
*/
len = sizeof(sin6);
if (getsockname(s, (struct sockaddr *)&sin6, (void *)&len) <
0) {
if (getsockname(s, (struct sockaddr *)&sin6, (void *)&len) < 0)
{
isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
ISC_LOGMODULE_SOCKET, ISC_LOG_ERROR,
"retrieving the address of an IPv6 "
@@ -191,8 +190,7 @@ try_proto(int domain)
}
static void
initialize_action(void)
{
initialize_action(void) {
ipv4_result = try_proto(PF_INET);
ipv6_result = try_proto(PF_INET6);
#ifdef ISC_PLATFORM_HAVESYSUNH
@@ -201,37 +199,32 @@ initialize_action(void)
}
static void
initialize(void)
{
initialize(void) {
RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS);
}
isc_result_t
isc_net_probeipv4(void)
{
isc_net_probeipv4(void) {
initialize();
return (ipv4_result);
}
isc_result_t
isc_net_probeipv6(void)
{
isc_net_probeipv6(void) {
initialize();
return (ipv6_result);
}
isc_result_t
isc_net_probeunix(void)
{
isc_net_probeunix(void) {
initialize();
return (unix_result);
}
static void
try_ipv6only(void)
{
try_ipv6only(void) {
#ifdef IPV6_V6ONLY
int s, on;
int s, on;
char strbuf[ISC_STRERRORSIZE];
#endif /* ifdef IPV6_V6ONLY */
isc_result_t result;
@@ -289,20 +282,18 @@ close:
}
static void
initialize_ipv6only(void)
{
initialize_ipv6only(void) {
RUNTIME_CHECK(isc_once_do(&once_ipv6only, try_ipv6only) ==
ISC_R_SUCCESS);
}
#ifdef __notyet__
static void
try_ipv6pktinfo(void)
{
int s, on;
char strbuf[ISC_STRERRORSIZE];
try_ipv6pktinfo(void) {
int s, on;
char strbuf[ISC_STRERRORSIZE];
isc_result_t result;
int optname;
int optname;
result = isc_net_probeipv6();
if (result != ISC_R_SUCCESS) {
@@ -339,23 +330,20 @@ close:
}
static void
initialize_ipv6pktinfo(void)
{
initialize_ipv6pktinfo(void) {
RUNTIME_CHECK(isc_once_do(&once_ipv6pktinfo, try_ipv6pktinfo) ==
ISC_R_SUCCESS);
}
#endif /* ifdef __notyet__ */
isc_result_t
isc_net_probe_ipv6only(void)
{
isc_net_probe_ipv6only(void) {
initialize_ipv6only();
return (ipv6only_result);
}
isc_result_t
isc_net_probe_ipv6pktinfo(void)
{
isc_net_probe_ipv6pktinfo(void) {
/*
* XXXWPK if pktinfo were supported then we could listen on :: for ipv6 and get
* the information about the destination address from pktinfo structure passed
@@ -374,8 +362,7 @@ isc_net_probe_ipv6pktinfo(void)
#if ISC_CMSG_IP_TOS || defined(IPV6_TCLASS)
static inline socklen_t
cmsg_len(socklen_t len)
{
cmsg_len(socklen_t len) {
#ifdef CMSG_LEN
return (CMSG_LEN(len));
#else /* ifdef CMSG_LEN */
@@ -391,12 +378,11 @@ cmsg_len(socklen_t len)
}
static inline socklen_t
cmsg_space(socklen_t len)
{
cmsg_space(socklen_t len) {
#ifdef CMSG_SPACE
return (CMSG_SPACE(len));
#else /* ifdef CMSG_SPACE */
struct msghdr msg;
struct msghdr msg;
struct cmsghdr *cmsgp;
/*
* XXX: The buffer length is an ad-hoc value, but should be enough
@@ -424,10 +410,9 @@ cmsg_space(socklen_t len)
* Make a fd non-blocking.
*/
static isc_result_t
make_nonblock(int fd)
{
int ret;
int flags;
make_nonblock(int fd) {
int ret;
int flags;
char strbuf[ISC_STRERRORSIZE];
#ifdef USE_FIONBIO_IOCTL
int on = 1;
@@ -456,21 +441,20 @@ make_nonblock(int fd)
}
static bool
cmsgsend(int s, int level, int type, struct addrinfo *res)
{
char strbuf[ISC_STRERRORSIZE];
cmsgsend(int s, int level, int type, struct addrinfo *res) {
char strbuf[ISC_STRERRORSIZE];
struct sockaddr_storage ss;
socklen_t len = sizeof(ss);
struct msghdr msg;
socklen_t len = sizeof(ss);
struct msghdr msg;
union {
struct cmsghdr h;
unsigned char b[256];
unsigned char b[256];
} control;
struct cmsghdr *cmsgp;
int dscp = (46 << 2); /* Expedited forwarding. */
struct iovec iovec;
char buf[1] = { 0 };
isc_result_t result;
int dscp = (46 << 2); /* Expedited forwarding. */
struct iovec iovec;
char buf[1] = { 0 };
isc_result_t result;
if (bind(s, res->ai_addr, res->ai_addrlen) < 0) {
strerror_r(errno, strbuf, sizeof(strbuf));
@@ -529,7 +513,7 @@ cmsgsend(int s, int level, int type, struct addrinfo *res)
}
if (sendmsg(s, &msg, 0) < 0) {
int debug = ISC_LOG_DEBUG(10);
int debug = ISC_LOG_DEBUG(10);
const char *typestr;
switch (errno) {
#ifdef ENOPROTOOPT
@@ -586,12 +570,11 @@ cmsgsend(int s, int level, int type, struct addrinfo *res)
#endif /* if ISC_CMSG_IP_TOS || defined(IPV6_TCLASS) */
static void
try_dscp_v4(void)
{
try_dscp_v4(void) {
#ifdef IP_TOS
char strbuf[ISC_STRERRORSIZE];
char strbuf[ISC_STRERRORSIZE];
struct addrinfo hints, *res0;
int s, dscp = 0, n;
int s, dscp = 0, n;
#ifdef IP_RECVTOS
int on = 1;
#endif /* IP_RECVTOS */
@@ -649,12 +632,11 @@ try_dscp_v4(void)
}
static void
try_dscp_v6(void)
{
try_dscp_v6(void) {
#ifdef IPV6_TCLASS
char strbuf[ISC_STRERRORSIZE];
char strbuf[ISC_STRERRORSIZE];
struct addrinfo hints, *res0;
int s, dscp = 0, n;
int s, dscp = 0, n;
#if defined(IPV6_RECVTCLASS)
int on = 1;
#endif /* IPV6_RECVTCLASS */
@@ -686,15 +668,15 @@ try_dscp_v6(void)
freeaddrinfo(res0);
return;
}
if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &dscp, sizeof(dscp)) ==
0) {
if (setsockopt(s, IPPROTO_IPV6, IPV6_TCLASS, &dscp, sizeof(dscp)) == 0)
{
dscp_result |= ISC_NET_DSCPSETV6;
}
#ifdef IPV6_RECVTCLASS
on = 1;
if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVTCLASS, &on, sizeof(on)) ==
0) {
if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVTCLASS, &on, sizeof(on)) == 0)
{
dscp_result |= ISC_NET_DSCPRECVV6;
}
#endif /* IPV6_RECVTCLASS */
@@ -710,21 +692,18 @@ try_dscp_v6(void)
}
static void
try_dscp(void)
{
try_dscp(void) {
try_dscp_v4();
try_dscp_v6();
}
static void
initialize_dscp(void)
{
initialize_dscp(void) {
RUNTIME_CHECK(isc_once_do(&once_dscp, try_dscp) == ISC_R_SUCCESS);
}
unsigned int
isc_net_probedscp(void)
{
isc_net_probedscp(void) {
initialize_dscp();
return (dscp_result);
}
@@ -732,10 +711,9 @@ isc_net_probedscp(void)
#if defined(USE_SYSCTL_PORTRANGE)
#if defined(HAVE_SYSCTLBYNAME)
static isc_result_t
getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high)
{
int port_low, port_high;
size_t portlen;
getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high) {
int port_low, port_high;
size_t portlen;
const char *sysctlname_lowport, *sysctlname_hiport;
if (af == AF_INET) {
@@ -746,13 +724,13 @@ getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high)
sysctlname_hiport = SYSCTL_V6PORTRANGE_HIGH;
}
portlen = sizeof(port_low);
if (sysctlbyname(sysctlname_lowport, &port_low, &portlen, NULL, 0) <
0) {
if (sysctlbyname(sysctlname_lowport, &port_low, &portlen, NULL, 0) < 0)
{
return (ISC_R_FAILURE);
}
portlen = sizeof(port_high);
if (sysctlbyname(sysctlname_hiport, &port_high, &portlen, NULL, 0) <
0) {
if (sysctlbyname(sysctlname_hiport, &port_high, &portlen, NULL, 0) < 0)
{
return (ISC_R_FAILURE);
}
if ((port_low & ~0xffff) != 0 || (port_high & ~0xffff) != 0) {
@@ -766,8 +744,7 @@ getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high)
}
#else /* !HAVE_SYSCTLBYNAME */
static isc_result_t
getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high)
{
getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high) {
int mib_lo4[4] = SYSCTL_V4PORTRANGE_LOW;
int mib_hi4[4] = SYSCTL_V4PORTRANGE_HIGH;
int mib_lo6[4] = SYSCTL_V6PORTRANGE_LOW;
@@ -809,8 +786,7 @@ getudpportrange_sysctl(int af, in_port_t *low, in_port_t *high)
#endif /* USE_SYSCTL_PORTRANGE */
isc_result_t
isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high)
{
isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high) {
int result = ISC_R_FAILURE;
#if !defined(USE_SYSCTL_PORTRANGE) && defined(__linux)
FILE *fp;
@@ -829,7 +805,7 @@ isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high)
*/
fp = fopen("/proc/sys/net/ipv4/ip_local_port_range", "r");
if (fp != NULL) {
int n;
int n;
unsigned int l, h;
n = fscanf(fp, "%u %u", &l, &h);
@@ -853,8 +829,7 @@ isc_net_getudpportrange(int af, in_port_t *low, in_port_t *high)
}
void
isc_net_disableipv4(void)
{
isc_net_disableipv4(void) {
initialize();
if (ipv4_result == ISC_R_SUCCESS) {
ipv4_result = ISC_R_DISABLED;
@@ -862,8 +837,7 @@ isc_net_disableipv4(void)
}
void
isc_net_disableipv6(void)
{
isc_net_disableipv6(void) {
initialize();
if (ipv6_result == ISC_R_SUCCESS) {
ipv6_result = ISC_R_DISABLED;
@@ -871,8 +845,7 @@ isc_net_disableipv6(void)
}
void
isc_net_enableipv4(void)
{
isc_net_enableipv4(void) {
initialize();
if (ipv4_result == ISC_R_DISABLED) {
ipv4_result = ISC_R_SUCCESS;
@@ -880,8 +853,7 @@ isc_net_enableipv4(void)
}
void
isc_net_enableipv6(void)
{
isc_net_enableipv6(void) {
initialize();
if (ipv6_result == ISC_R_DISABLED) {
ipv6_result = ISC_R_SUCCESS;

View File

@@ -16,8 +16,7 @@
#include <unistd.h>
static inline long
sysconf_ncpus(void)
{
sysconf_ncpus(void) {
#if defined(_SC_NPROCESSORS_ONLN)
return (sysconf((_SC_NPROCESSORS_ONLN)));
#elif defined(_SC_NPROC_ONLN)
@@ -34,9 +33,8 @@ sysconf_ncpus(void)
#include <sys/types.h> /* for FreeBSD */
static int
sysctl_ncpus(void)
{
int ncpu, result;
sysctl_ncpus(void) {
int ncpu, result;
size_t len;
len = sizeof(ncpu);
@@ -49,8 +47,7 @@ sysctl_ncpus(void)
#endif /* if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME) */
unsigned int
isc_os_ncpus(void)
{
isc_os_ncpus(void) {
long ncpus = 0;
#if defined(HAVE_SYSCONF)

View File

@@ -29,11 +29,10 @@
#include <pk11/pk11.h>
static void *hPK11 = NULL;
static char loaderrmsg[1024];
static char loaderrmsg[1024];
CK_RV
pkcs_C_Initialize(CK_VOID_PTR pReserved)
{
pkcs_C_Initialize(CK_VOID_PTR pReserved) {
CK_C_Initialize sym;
if (hPK11 != NULL) {
@@ -56,16 +55,14 @@ pkcs_C_Initialize(CK_VOID_PTR pReserved)
}
char *
pk11_get_load_error_message(void)
{
pk11_get_load_error_message(void) {
return (loaderrmsg);
}
CK_RV
pkcs_C_Finalize(CK_VOID_PTR pReserved)
{
pkcs_C_Finalize(CK_VOID_PTR pReserved) {
CK_C_Finalize sym;
CK_RV rv;
CK_RV rv;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -84,10 +81,9 @@ pkcs_C_Finalize(CK_VOID_PTR pReserved)
CK_RV
pkcs_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList,
CK_ULONG_PTR pulCount)
{
CK_ULONG_PTR pulCount) {
static CK_C_GetSlotList sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -103,10 +99,9 @@ pkcs_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList,
}
CK_RV
pkcs_C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo)
{
pkcs_C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo) {
static CK_C_GetTokenInfo sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -123,10 +118,9 @@ pkcs_C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo)
CK_RV
pkcs_C_GetMechanismInfo(CK_SLOT_ID slotID, CK_MECHANISM_TYPE type,
CK_MECHANISM_INFO_PTR pInfo)
{
CK_MECHANISM_INFO_PTR pInfo) {
static CK_C_GetMechanismInfo sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -144,12 +138,11 @@ pkcs_C_GetMechanismInfo(CK_SLOT_ID slotID, CK_MECHANISM_TYPE type,
CK_RV
pkcs_C_OpenSession(CK_SLOT_ID slotID, CK_FLAGS flags, CK_VOID_PTR pApplication,
CK_RV (*Notify)(CK_SESSION_HANDLE hSession,
CK_NOTIFICATION event,
CK_VOID_PTR pApplication),
CK_SESSION_HANDLE_PTR phSession)
{
CK_NOTIFICATION event,
CK_VOID_PTR pApplication),
CK_SESSION_HANDLE_PTR phSession) {
static CK_C_OpenSession sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
hPK11 = dlopen(pk11_get_lib_name(), RTLD_NOW);
@@ -171,10 +164,9 @@ pkcs_C_OpenSession(CK_SLOT_ID slotID, CK_FLAGS flags, CK_VOID_PTR pApplication,
}
CK_RV
pkcs_C_CloseSession(CK_SESSION_HANDLE hSession)
{
pkcs_C_CloseSession(CK_SESSION_HANDLE hSession) {
static CK_C_CloseSession sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -191,10 +183,9 @@ pkcs_C_CloseSession(CK_SESSION_HANDLE hSession)
CK_RV
pkcs_C_Login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType,
CK_CHAR_PTR pPin, CK_ULONG usPinLen)
{
CK_CHAR_PTR pPin, CK_ULONG usPinLen) {
static CK_C_Login sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -210,10 +201,9 @@ pkcs_C_Login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType,
}
CK_RV
pkcs_C_Logout(CK_SESSION_HANDLE hSession)
{
pkcs_C_Logout(CK_SESSION_HANDLE hSession) {
static CK_C_Logout sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -230,10 +220,9 @@ pkcs_C_Logout(CK_SESSION_HANDLE hSession)
CK_RV
pkcs_C_CreateObject(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG usCount, CK_OBJECT_HANDLE_PTR phObject)
{
CK_ULONG usCount, CK_OBJECT_HANDLE_PTR phObject) {
static CK_C_CreateObject sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -249,10 +238,9 @@ pkcs_C_CreateObject(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
}
CK_RV
pkcs_C_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject)
{
pkcs_C_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject) {
static CK_C_DestroyObject sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -269,10 +257,9 @@ pkcs_C_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject)
CK_RV
pkcs_C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount)
{
CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount) {
static CK_C_GetAttributeValue sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -290,10 +277,9 @@ pkcs_C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
CK_RV
pkcs_C_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount)
{
CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount) {
static CK_C_SetAttributeValue sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -311,10 +297,9 @@ pkcs_C_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
CK_RV
pkcs_C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG usCount)
{
CK_ULONG usCount) {
static CK_C_FindObjectsInit sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -331,10 +316,9 @@ pkcs_C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
CK_RV
pkcs_C_FindObjects(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phObject,
CK_ULONG usMaxObjectCount, CK_ULONG_PTR pusObjectCount)
{
CK_ULONG usMaxObjectCount, CK_ULONG_PTR pusObjectCount) {
static CK_C_FindObjects sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -350,10 +334,9 @@ pkcs_C_FindObjects(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phObject,
}
CK_RV
pkcs_C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
{
pkcs_C_FindObjectsFinal(CK_SESSION_HANDLE hSession) {
static CK_C_FindObjectsFinal sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -370,10 +353,9 @@ pkcs_C_FindObjectsFinal(CK_SESSION_HANDLE hSession)
CK_RV
pkcs_C_EncryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey)
{
CK_OBJECT_HANDLE hKey) {
static CK_C_EncryptInit sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -391,10 +373,9 @@ pkcs_C_EncryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_RV
pkcs_C_Encrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
CK_ULONG ulDataLen, CK_BYTE_PTR pEncryptedData,
CK_ULONG_PTR pulEncryptedDataLen)
{
CK_ULONG_PTR pulEncryptedDataLen) {
static CK_C_Encrypt sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -411,10 +392,9 @@ pkcs_C_Encrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData,
}
CK_RV
pkcs_C_DigestInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism)
{
pkcs_C_DigestInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism) {
static CK_C_DigestInit sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -431,10 +411,9 @@ pkcs_C_DigestInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism)
CK_RV
pkcs_C_DigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
CK_ULONG ulPartLen)
{
CK_ULONG ulPartLen) {
static CK_C_DigestUpdate sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -451,10 +430,9 @@ pkcs_C_DigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
CK_RV
pkcs_C_DigestFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pDigest,
CK_ULONG_PTR pulDigestLen)
{
CK_ULONG_PTR pulDigestLen) {
static CK_C_DigestFinal sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -471,10 +449,9 @@ pkcs_C_DigestFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pDigest,
CK_RV
pkcs_C_SignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey)
{
CK_OBJECT_HANDLE hKey) {
static CK_C_SignInit sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -491,10 +468,9 @@ pkcs_C_SignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_RV
pkcs_C_Sign(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen)
{
CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen) {
static CK_C_Sign sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -512,10 +488,9 @@ pkcs_C_Sign(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
CK_RV
pkcs_C_SignUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
CK_ULONG ulPartLen)
{
CK_ULONG ulPartLen) {
static CK_C_SignUpdate sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -532,10 +507,9 @@ pkcs_C_SignUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
CK_RV
pkcs_C_SignFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
CK_ULONG_PTR pulSignatureLen)
{
CK_ULONG_PTR pulSignatureLen) {
static CK_C_SignFinal sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -552,10 +526,9 @@ pkcs_C_SignFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
CK_RV
pkcs_C_VerifyInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hKey)
{
CK_OBJECT_HANDLE hKey) {
static CK_C_VerifyInit sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -572,10 +545,9 @@ pkcs_C_VerifyInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_RV
pkcs_C_Verify(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
CK_BYTE_PTR pSignature, CK_ULONG ulSignatureLen)
{
CK_BYTE_PTR pSignature, CK_ULONG ulSignatureLen) {
static CK_C_Verify sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -592,10 +564,9 @@ pkcs_C_Verify(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG ulDataLen,
CK_RV
pkcs_C_VerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
CK_ULONG ulPartLen)
{
CK_ULONG ulPartLen) {
static CK_C_VerifyUpdate sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -612,10 +583,9 @@ pkcs_C_VerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart,
CK_RV
pkcs_C_VerifyFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
CK_ULONG ulSignatureLen)
{
CK_ULONG ulSignatureLen) {
static CK_C_VerifyFinal sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -633,10 +603,9 @@ pkcs_C_VerifyFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature,
CK_RV
pkcs_C_GenerateKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
CK_OBJECT_HANDLE_PTR phKey)
{
CK_OBJECT_HANDLE_PTR phKey) {
static CK_C_GenerateKey sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -653,15 +622,14 @@ pkcs_C_GenerateKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_RV
pkcs_C_GenerateKeyPair(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_ATTRIBUTE_PTR pPublicKeyTemplate,
CK_ULONG usPublicKeyAttributeCount,
CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
CK_ULONG usPrivateKeyAttributeCount,
CK_ATTRIBUTE_PTR pPublicKeyTemplate,
CK_ULONG usPublicKeyAttributeCount,
CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
CK_ULONG usPrivateKeyAttributeCount,
CK_OBJECT_HANDLE_PTR phPrivateKey,
CK_OBJECT_HANDLE_PTR phPublicKey)
{
CK_OBJECT_HANDLE_PTR phPublicKey) {
static CK_C_GenerateKeyPair sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -681,10 +649,9 @@ pkcs_C_GenerateKeyPair(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_RV
pkcs_C_DeriveKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_OBJECT_HANDLE hBaseKey, CK_ATTRIBUTE_PTR pTemplate,
CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey)
{
CK_ULONG ulAttributeCount, CK_OBJECT_HANDLE_PTR phKey) {
static CK_C_DeriveKey sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -702,10 +669,9 @@ pkcs_C_DeriveKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
CK_RV
pkcs_C_SeedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed,
CK_ULONG ulSeedLen)
{
CK_ULONG ulSeedLen) {
static CK_C_SeedRandom sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);
@@ -722,10 +688,9 @@ pkcs_C_SeedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed,
CK_RV
pkcs_C_GenerateRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR RandomData,
CK_ULONG ulRandomLen)
{
CK_ULONG ulRandomLen) {
static CK_C_GenerateRandom sym = NULL;
static void * pPK11 = NULL;
static void *pPK11 = NULL;
if (hPK11 == NULL) {
return (CKR_LIBRARY_LOAD_FAILED);

View File

@@ -28,8 +28,7 @@
#include "errno2result.h"
static isc_result_t
resource2rlim(isc_resource_t resource, int *rlim_resource)
{
resource2rlim(isc_resource_t resource, int *rlim_resource) {
isc_result_t result = ISC_R_SUCCESS;
switch (resource) {
@@ -92,13 +91,12 @@ resource2rlim(isc_resource_t resource, int *rlim_resource)
}
isc_result_t
isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value)
{
isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
struct rlimit rl;
rlim_t rlim_value;
int unixresult;
int unixresource;
isc_result_t result;
rlim_t rlim_value;
int unixresult;
int unixresource;
isc_result_t result;
result = resource2rlim(resource, &unixresource);
if (result != ISC_R_SUCCESS) {
@@ -182,11 +180,10 @@ isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value)
}
isc_result_t
isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value)
{
int unixresource;
isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
int unixresource;
struct rlimit rl;
isc_result_t result;
isc_result_t result;
result = resource2rlim(resource, &unixresource);
if (result != ISC_R_SUCCESS) {
@@ -202,11 +199,10 @@ isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value)
}
isc_result_t
isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value)
{
int unixresource;
isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
int unixresource;
struct rlimit rl;
isc_result_t result;
isc_result_t result;
result = resource2rlim(resource, &unixresource);
if (result != ISC_R_SUCCESS) {

File diff suppressed because it is too large Load Diff

View File

@@ -19,8 +19,7 @@
#include "errno2result.h"
isc_result_t
isc_stdio_open(const char *filename, const char *mode, FILE **fp)
{
isc_stdio_open(const char *filename, const char *mode, FILE **fp) {
FILE *f;
f = fopen(filename, mode);
@@ -32,8 +31,7 @@ isc_stdio_open(const char *filename, const char *mode, FILE **fp)
}
isc_result_t
isc_stdio_close(FILE *f)
{
isc_stdio_close(FILE *f) {
int r;
r = fclose(f);
@@ -45,8 +43,7 @@ isc_stdio_close(FILE *f)
}
isc_result_t
isc_stdio_seek(FILE *f, off_t offset, int whence)
{
isc_stdio_seek(FILE *f, off_t offset, int whence) {
int r;
r = fseeko(f, offset, whence);
@@ -58,8 +55,7 @@ isc_stdio_seek(FILE *f, off_t offset, int whence)
}
isc_result_t
isc_stdio_tell(FILE *f, off_t *offsetp)
{
isc_stdio_tell(FILE *f, off_t *offsetp) {
off_t r;
REQUIRE(offsetp != NULL);
@@ -74,10 +70,9 @@ isc_stdio_tell(FILE *f, off_t *offsetp)
}
isc_result_t
isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret)
{
isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret) {
isc_result_t result = ISC_R_SUCCESS;
size_t r;
size_t r;
clearerr(f);
r = fread(ptr, size, nmemb, f);
@@ -96,10 +91,9 @@ isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret)
isc_result_t
isc_stdio_write(const void *ptr, size_t size, size_t nmemb, FILE *f,
size_t *nret)
{
size_t *nret) {
isc_result_t result = ISC_R_SUCCESS;
size_t r;
size_t r;
clearerr(f);
r = fwrite(ptr, size, nmemb, f);
@@ -113,8 +107,7 @@ isc_stdio_write(const void *ptr, size_t size, size_t nmemb, FILE *f,
}
isc_result_t
isc_stdio_flush(FILE *f)
{
isc_stdio_flush(FILE *f) {
int r;
r = fflush(f);
@@ -133,10 +126,9 @@ isc_stdio_flush(FILE *f)
#endif /* if defined(EOPNOTSUPP) && !defined(ENOTSUP) */
isc_result_t
isc_stdio_sync(FILE *f)
{
isc_stdio_sync(FILE *f) {
struct stat buf;
int r;
int r;
if (fstat(fileno(f), &buf) != 0) {
return (isc__errno2result(errno));

View File

@@ -29,8 +29,7 @@
#if ISC_FIX_TV_USEC
static inline void
fix_tv_usec(struct timeval *tv)
{
fix_tv_usec(struct timeval *tv) {
bool fixed = false;
if (tv->tv_usec < 0) {
@@ -57,8 +56,7 @@ fix_tv_usec(struct timeval *tv)
#endif /* if ISC_FIX_TV_USEC */
void
isc_stdtime_get(isc_stdtime_t *t)
{
isc_stdtime_get(isc_stdtime_t *t) {
struct timeval tv;
/*

View File

@@ -20,7 +20,7 @@
#include <isc/util.h>
static struct dsn_c_pvt_sfnt {
int val;
int val;
const char *strval;
} facilities[] = { { LOG_KERN, "kern" },
{ LOG_USER, "user" },
@@ -55,8 +55,7 @@ static struct dsn_c_pvt_sfnt {
{ 0, NULL } };
isc_result_t
isc_syslog_facilityfromstring(const char *str, int *facilityp)
{
isc_syslog_facilityfromstring(const char *str, int *facilityp) {
int i;
REQUIRE(str != NULL);

View File

@@ -30,10 +30,10 @@
#include <sys/time.h> /* Required for struct timeval on some platforms. */
#define NS_PER_S 1000000000 /*%< Nanoseconds per second. */
#define NS_PER_US 1000 /*%< Nanoseconds per microsecond. */
#define NS_PER_MS 1000000 /*%< Nanoseconds per millisecond. */
#define US_PER_S 1000000 /*%< Microseconds per second. */
#define NS_PER_S 1000000000 /*%< Nanoseconds per second. */
#define NS_PER_US 1000 /*%< Nanoseconds per microsecond. */
#define NS_PER_MS 1000000 /*%< Nanoseconds per millisecond. */
#define US_PER_S 1000000 /*%< Microseconds per second. */
#if defined(CLOCK_REALTIME_COARSE)
#define CLOCKSOURCE CLOCK_REALTIME_COARSE
@@ -52,8 +52,7 @@ const isc_interval_t *const isc_interval_zero = &zero_interval;
void
isc_interval_set(isc_interval_t *i, unsigned int seconds,
unsigned int nanoseconds)
{
unsigned int nanoseconds) {
REQUIRE(i != NULL);
REQUIRE(nanoseconds < NS_PER_S);
@@ -62,8 +61,7 @@ isc_interval_set(isc_interval_t *i, unsigned int seconds,
}
bool
isc_interval_iszero(const isc_interval_t *i)
{
isc_interval_iszero(const isc_interval_t *i) {
REQUIRE(i != NULL);
INSIST(i->nanoseconds < NS_PER_S);
@@ -82,8 +80,7 @@ static const isc_time_t epoch = { 0, 0 };
const isc_time_t *const isc_time_epoch = &epoch;
void
isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds)
{
isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
REQUIRE(t != NULL);
REQUIRE(nanoseconds < NS_PER_S);
@@ -92,8 +89,7 @@ isc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds)
}
void
isc_time_settoepoch(isc_time_t *t)
{
isc_time_settoepoch(isc_time_t *t) {
REQUIRE(t != NULL);
t->seconds = 0;
@@ -101,8 +97,7 @@ isc_time_settoepoch(isc_time_t *t)
}
bool
isc_time_isepoch(const isc_time_t *t)
{
isc_time_isepoch(const isc_time_t *t) {
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -114,10 +109,9 @@ isc_time_isepoch(const isc_time_t *t)
}
isc_result_t
isc_time_now(isc_time_t *t)
{
isc_time_now(isc_time_t *t) {
struct timespec ts;
char strbuf[ISC_STRERRORSIZE];
char strbuf[ISC_STRERRORSIZE];
REQUIRE(t != NULL);
@@ -135,7 +129,8 @@ isc_time_now(isc_time_t *t)
* Ensure the tv_sec value fits in t->seconds.
*/
if (sizeof(ts.tv_sec) > sizeof(t->seconds) &&
((ts.tv_sec | (unsigned int)-1) ^ (unsigned int)-1) != 0U) {
((ts.tv_sec | (unsigned int)-1) ^ (unsigned int)-1) != 0U)
{
return (ISC_R_RANGE);
}
@@ -146,10 +141,9 @@ isc_time_now(isc_time_t *t)
}
isc_result_t
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i)
{
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
struct timespec ts;
char strbuf[ISC_STRERRORSIZE];
char strbuf[ISC_STRERRORSIZE];
REQUIRE(t != NULL);
REQUIRE(i != NULL);
@@ -172,7 +166,8 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i)
* and getting another 1 added below the result is UINT_MAX.)
*/
if ((ts.tv_sec > INT_MAX || i->seconds > INT_MAX) &&
((long long)ts.tv_sec + i->seconds > UINT_MAX)) {
((long long)ts.tv_sec + i->seconds > UINT_MAX))
{
return (ISC_R_RANGE);
}
@@ -187,8 +182,7 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i)
}
int
isc_time_compare(const isc_time_t *t1, const isc_time_t *t2)
{
isc_time_compare(const isc_time_t *t1, const isc_time_t *t2) {
REQUIRE(t1 != NULL && t2 != NULL);
INSIST(t1->nanoseconds < NS_PER_S && t2->nanoseconds < NS_PER_S);
@@ -208,8 +202,7 @@ isc_time_compare(const isc_time_t *t1, const isc_time_t *t2)
}
isc_result_t
isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result)
{
isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result) {
REQUIRE(t != NULL && i != NULL && result != NULL);
INSIST(t->nanoseconds < NS_PER_S && i->nanoseconds < NS_PER_S);
@@ -220,7 +213,8 @@ isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result)
* and getting another 1 added below the result is UINT_MAX.)
*/
if ((t->seconds > INT_MAX || i->seconds > INT_MAX) &&
((long long)t->seconds + i->seconds > UINT_MAX)) {
((long long)t->seconds + i->seconds > UINT_MAX))
{
return (ISC_R_RANGE);
}
@@ -236,14 +230,14 @@ isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result)
isc_result_t
isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
isc_time_t *result)
{
isc_time_t *result) {
REQUIRE(t != NULL && i != NULL && result != NULL);
INSIST(t->nanoseconds < NS_PER_S && i->nanoseconds < NS_PER_S);
if ((unsigned int)t->seconds < i->seconds ||
((unsigned int)t->seconds == i->seconds &&
t->nanoseconds < i->nanoseconds)) {
t->nanoseconds < i->nanoseconds))
{
return (ISC_R_RANGE);
}
@@ -251,8 +245,8 @@ isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
if (t->nanoseconds >= i->nanoseconds) {
result->nanoseconds = t->nanoseconds - i->nanoseconds;
} else {
result->nanoseconds =
NS_PER_S - i->nanoseconds + t->nanoseconds;
result->nanoseconds = NS_PER_S - i->nanoseconds +
t->nanoseconds;
result->seconds--;
}
@@ -260,8 +254,7 @@ isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
}
uint64_t
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2)
{
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
uint64_t i1, i2, i3;
REQUIRE(t1 != NULL && t2 != NULL);
@@ -285,8 +278,7 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2)
}
uint32_t
isc_time_seconds(const isc_time_t *t)
{
isc_time_seconds(const isc_time_t *t) {
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -294,8 +286,7 @@ isc_time_seconds(const isc_time_t *t)
}
isc_result_t
isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp)
{
isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp) {
time_t seconds;
REQUIRE(t != NULL);
@@ -333,8 +324,7 @@ isc_time_secondsastimet(const isc_time_t *t, time_t *secondsp)
}
uint32_t
isc_time_nanoseconds(const isc_time_t *t)
{
isc_time_nanoseconds(const isc_time_t *t) {
REQUIRE(t != NULL);
ENSURE(t->nanoseconds < NS_PER_S);
@@ -343,11 +333,10 @@ isc_time_nanoseconds(const isc_time_t *t)
}
void
isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len)
{
time_t now;
isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
struct tm tm;
struct tm tm;
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -366,11 +355,10 @@ isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len)
}
void
isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len)
{
time_t now;
isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
struct tm tm;
struct tm tm;
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -387,11 +375,10 @@ isc_time_formathttptimestamp(const isc_time_t *t, char *buf, unsigned int len)
}
isc_result_t
isc_time_parsehttptimestamp(char *buf, isc_time_t *t)
{
isc_time_parsehttptimestamp(char *buf, isc_time_t *t) {
struct tm t_tm;
time_t when;
char * p;
time_t when;
char *p;
REQUIRE(buf != NULL);
REQUIRE(t != NULL);
@@ -409,11 +396,10 @@ isc_time_parsehttptimestamp(char *buf, isc_time_t *t)
}
void
isc_time_formatISO8601L(const isc_time_t *t, char *buf, unsigned int len)
{
time_t now;
isc_time_formatISO8601L(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
struct tm tm;
struct tm tm;
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -426,11 +412,10 @@ isc_time_formatISO8601L(const isc_time_t *t, char *buf, unsigned int len)
}
void
isc_time_formatISO8601Lms(const isc_time_t *t, char *buf, unsigned int len)
{
time_t now;
isc_time_formatISO8601Lms(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
struct tm tm;
struct tm tm;
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -447,11 +432,10 @@ isc_time_formatISO8601Lms(const isc_time_t *t, char *buf, unsigned int len)
}
void
isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len)
{
time_t now;
isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
struct tm tm;
struct tm tm;
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -464,11 +448,10 @@ isc_time_formatISO8601(const isc_time_t *t, char *buf, unsigned int len)
}
void
isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len)
{
time_t now;
isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len) {
time_t now;
unsigned int flen;
struct tm tm;
struct tm tm;
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);
@@ -486,11 +469,11 @@ isc_time_formatISO8601ms(const isc_time_t *t, char *buf, unsigned int len)
}
void
isc_time_formatshorttimestamp(const isc_time_t *t, char *buf, unsigned int len)
{
time_t now;
isc_time_formatshorttimestamp(const isc_time_t *t, char *buf,
unsigned int len) {
time_t now;
unsigned int flen;
struct tm tm;
struct tm tm;
REQUIRE(t != NULL);
INSIST(t->nanoseconds < NS_PER_S);