Commit dc7a4a5c authored by Vincent Pelletier's avatar Vincent Pelletier

Style: evaluate false expressions to boolean, just as true expressions.

parent 43ec3fd9
......@@ -48,7 +48,7 @@ static inline void *dlsym_or_abort(const char *name) {
void *symbol;
dlerror(); /* Clear any previous error */
symbol = dlsym(RTLD_NEXT, name);
if (NULL == symbol && (error = dlerror())) {
if (!symbol && (error = dlerror())) {
fprintf(stderr, "Error loading '%s': %s\n", name, error);
abort();
}
......@@ -59,13 +59,13 @@ static void __attribute__ ((constructor)) init(void) {
original_open = dlsym_or_abort("open");
original_fopen = dlsym_or_abort("fopen");
replacement_hosts = getenv("HOSTS");
if (replacement_hosts == NULL)
if (!replacement_hosts)
/* XXX: warn ? fallback on $HOME/???/hosts ? */
replacement_hosts = ORIGINAL_HOSTS_PATH;
}
int open(const char *__file, int __oflag, ...) {
if (strcmp(__file, ORIGINAL_HOSTS_PATH) == 0)
if (!strcmp(__file, ORIGINAL_HOSTS_PATH))
__file = replacement_hosts;
if (__oflag & (O_CREAT | PURE_O_TMPFILE)) {
va_list ap;
......@@ -80,7 +80,7 @@ int open(const char *__file, int __oflag, ...) {
}
FILE *fopen(const char *path, const char *mode) {
if (strcmp(path, ORIGINAL_HOSTS_PATH) == 0)
if (!strcmp(path, ORIGINAL_HOSTS_PATH))
path = replacement_hosts;
return (*original_fopen)(path, mode);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment