return NULL;
#ifdef DEBUG_MEMORY
- if (!lbuf)
+ if (lbuf == NULL)
atexit(free_lbuf);
#endif
last = 0;
do {
- if (!lbuf || last != 0) {
+ if (lbuf == NULL || last != 0) {
lbuf_len += BUFSIZ;
lbuf = xrealloc(lbuf, lbuf_len);
}
memset(p, 0, BUFSIZ);
fgets(p, BUFSIZ, fp);
last += strlen(p);
- if (last && lbuf[last - 1] == '\n') {
+ if (last != 0 && lbuf[last - 1] == '\n') {
lbuf[last - 1] = '\0';
break;
}
} while(!feof(fp));
- if (!last)
+ if (last == 0)
return NULL;
e = p + last - 1;
uint32_t arc4random(void)
{
int fd;
- static unsigned long seed = 0;
+ static unsigned long seed;
- if (!seed) {
+ if (seed == 0) {
fd = open("/dev/urandom", 0);
if (fd == -1 || read(fd, &seed, sizeof(seed)) == -1)
seed = time(0);
struct timespec ts;
static clockid_t posix_clock;
- if (posix_clock_set == 0) {
+ if (!posix_clock_set) {
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
posix_clock = CLOCK_MONOTONIC;
clock_monotonic = posix_clock_set = 1;
uint64_t nano;
long rem;
- if (posix_clock_set == 0) {
+ if (!posix_clock_set) {
if (mach_timebase_info(&info) == KERN_SUCCESS) {
factor = (double)info.numer / (double)info.denom;
clock_monotonic = posix_clock_set = 1;
{
void *value = malloc(s);
- if (value)
+ if (value != NULL)
return value;
syslog(LOG_ERR, "memory exhausted (xalloc %zu bytes)", s);
exit (EXIT_FAILURE);
{
void *value = realloc(ptr, s);
- if (value)
- return (value);
+ if (value != NULL)
+ return value;
syslog(LOG_ERR, "memory exhausted (xrealloc %zu bytes)", s);
exit(EXIT_FAILURE);
/* NOTREACHED */
{
char *value;
- if (!str)
+ if (str = NULL)
return NULL;
- if ((value = strdup(str)))
+ if ((value = strdup(str)) != NULL)
return value;
syslog(LOG_ERR, "memory exhausted (xstrdup)");