bool net2str(char *netstr, int len, const subnet_t *subnet) {
if(!netstr || !subnet) {
- logger(LOG_ERR, "net2str() was called with netstr=%p, subnet=%p!", netstr, subnet);
+ logger(LOG_ERR, "net2str() was called with netstr=%p, subnet=%p!", (void *)netstr, (void *)subnet);
return false;
}
// Prepare environment variables to be passed to the script
- xasprintf(&envp[0], "NETNAME=%s", netname ? : "");
- xasprintf(&envp[1], "DEVICE=%s", device ? : "");
- xasprintf(&envp[2], "INTERFACE=%s", iface ? : "");
+ xasprintf(&envp[0], "NETNAME=%s", netname ? netname : "");
+ xasprintf(&envp[1], "DEVICE=%s", device ? device : "");
+ xasprintf(&envp[2], "INTERFACE=%s", iface ? iface : "");
xasprintf(&envp[3], "NODE=%s", owner->name);
xasprintf(&envp[4], "NAME=%s", myself->name);
}
// Prepare the SUBNET and WEIGHT variables
- if(envp[5]) {
- free(envp[5]);
- }
-
- if(envp[6]) {
- free(envp[6]);
- }
+ free(envp[5]);
+ free(envp[6]);
xasprintf(&envp[5], "SUBNET=%s", netstr);
xasprintf(&envp[6], "WEIGHT=%s", weight);
}
}
- for(i = 0; envp[i] && i < 9; i++) {
+ for(i = 0; i < 9; i++) {
free(envp[i]);
}
}