case DEVICE_TYPE_UTUN:
case DEVICE_TYPE_TUNIFHEAD: {
- if((inlen = read(device_fd, DATA(packet) + 10, MTU - 10)) <= 0) {
+ inlen = read(device_fd, DATA(packet) + 10, MTU - 10);
+
+ if(inlen <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
case DEVICE_TYPE_VMNET:
#endif
case DEVICE_TYPE_TAP:
- if((inlen = read(device_fd, DATA(packet), MTU)) <= 0) {
+ inlen = read(device_fd, DATA(packet), MTU);
+
+ if(inlen <= 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while reading from %s %s: %s", device_info,
device, strerror(errno));
return false;
return false;
}
- if((err = gcry_cipher_open(&cipher->handle, algo, mode, 0))) {
+ err = gcry_cipher_open(&cipher->handle, algo, mode, 0);
+
+ if(err) {
logger(DEBUG_ALWAYS, LOG_DEBUG, "Unable to initialise cipher %d mode %d: %s", algo, mode, gcry_strerror(err));
return false;
}
gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen);
}
- if((err = gcry_cipher_encrypt(cipher->handle, outdata, *outlen, indata, inlen))) {
+ err = gcry_cipher_encrypt(cipher->handle, outdata, *outlen, indata, inlen);
+
+ if(err) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while encrypting: %s", gcry_strerror(err));
return false;
}
if(cipher->padding) {
- if((err = gcry_cipher_encrypt(cipher->handle, (char *)outdata + inlen, cipher->blklen, pad, cipher->blklen))) {
+ err = gcry_cipher_encrypt(cipher->handle, (char *)outdata + inlen, cipher->blklen, pad, cipher->blklen);
+
+ if(err) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while encrypting: %s", gcry_strerror(err));
return false;
}
gcry_cipher_setiv(cipher->handle, cipher->key + cipher->keylen, cipher->blklen);
}
- if((err = gcry_cipher_decrypt(cipher->handle, outdata, *outlen, indata, inlen))) {
+ err = gcry_cipher_decrypt(cipher->handle, outdata, *outlen, indata, inlen);
+
+ if(err) {
logger(DEBUG_ALWAYS, LOG_ERR, "Error while decrypting: %s", gcry_strerror(err));
return false;
}
get_config_string(lookup_config(&config_tree, "Interface"), &iface);
- if((write_fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) {
+ write_fd = socket(PF_UNIX, SOCK_DGRAM, 0);
+
+ if(write_fd < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not open write %s: %s", device_info, strerror(errno));
event_exit();
return false;
return false;
}
- if((data_fd = socket(PF_UNIX, SOCK_DGRAM, 0)) < 0) {
+ data_fd = socket(PF_UNIX, SOCK_DGRAM, 0);
+
+ if(data_fd < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not open data %s: %s", device_info, strerror(errno));
event_exit();
return false;
return false;
}
- if((listen_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
+ listen_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+
+ if(listen_fd < 0) {
logger(DEBUG_ALWAYS, LOG_ERR, "Could not open %s: %s", device_info,
strerror(errno));
return false;
strncpy(ext, p, pathlen + 1);
}
- if((found = !access(fullname, F_OK))) {
+ found = !access(fullname, F_OK);
+
+ if(found) {
break;
}
char *slash = strrchr(program_name, '/');
#ifdef HAVE_WINDOWS
+ c = strrchr(program_name, '\\');
- if((c = strrchr(program_name, '\\')) > slash) {
+ if(c > slash) {
slash = c;
}
strncpy(buf, "(unable to format errormessage)", sizeof(buf));
};
- if((ptr = strchr(buf, '\r'))) {
+ ptr = strchr(buf, '\r');
+
+ if(ptr) {
*ptr = '\0';
}
strncpy(buf, "(unable to format errormessage)", sizeof(buf));
};
- if((ptr = strchr(buf, '\r'))) {
+ ptr = strchr(buf, '\r');
+
+ if(ptr) {
*ptr = '\0';
}
DIR *d = opendir(container);
assert_non_null(d);
+ if (!d) {
+ abort();
+ }
+
struct dirent *ent;
while((ent = readdir(d))) {