if (strcmp(s->type, "forwarding"))
continue;
- forward = malloc(sizeof(*forward));
-
+ forward = calloc(1, sizeof(*forward));
if (!forward)
continue;
- memset(forward, 0, sizeof(*forward));
-
forward->enabled = true;
fw3_parse_options(forward, fw3_forward_opts, s);
if (strcmp(s->type, "include"))
continue;
- include = malloc(sizeof(*include));
-
+ include = calloc(1, sizeof(*include));
if (!include)
continue;
- memset(include, 0, sizeof(*include));
-
include->name = e->name;
include->enabled = true;
{
struct fw3_ipset *ipset;
- ipset = malloc(sizeof(*ipset));
-
+ ipset = calloc(1, sizeof(*ipset));
if (!ipset)
return NULL;
- memset(ipset, 0, sizeof(*ipset));
-
INIT_LIST_HEAD(&ipset->datatypes);
ipset->enabled = true;
struct uci_package *p = NULL;
FILE *sf;
- state = malloc(sizeof(*state));
-
+ state = calloc(1, sizeof(*state));
if (!state)
error("Out of memory");
- memset(state, 0, sizeof(*state));
state->uci = uci_alloc_context();
if (!state->uci)
if (strcmp(s->type, "redirect"))
continue;
- redir = malloc(sizeof(*redir));
-
+ redir = calloc(1, sizeof(*redir));
if (!redir)
continue;
- memset(redir, 0, sizeof(*redir));
-
INIT_LIST_HEAD(&redir->proto);
INIT_LIST_HEAD(&redir->mac_src);
struct blob_attr *cur;
struct fw3_address *addr;
- addr = malloc(sizeof(*addr));
-
+ addr = calloc(1, sizeof(*addr));
if (!addr)
return NULL;
- memset(addr, 0, sizeof(*addr));
-
addr->set = true;
addr->family = family;
return NULL;
if (device)
- dev = malloc(sizeof(*dev));
+ dev = calloc(1, sizeof(*dev));
else
addr = malloc(sizeof(*addr));
if ((device && !dev) || (!device && !addr))
goto fail;
- if (device)
- memset(dev, 0, sizeof(*dev));
- else
+ if (!device)
INIT_LIST_HEAD(addr);
blobmsg_for_each_attr(c, interfaces, r) {
return false;
argn = 2;
- args = malloc(argn * sizeof(arg));
+ args = calloc(argn, sizeof(arg));
if (!args)
return false;
{
struct fw3_zone *zone;
- zone = malloc(sizeof(*zone));
-
+ zone = calloc(1, sizeof(*zone));
if (!zone)
return NULL;
- memset(zone, 0, sizeof(*zone));
-
INIT_LIST_HEAD(&zone->networks);
INIT_LIST_HEAD(&zone->devices);
INIT_LIST_HEAD(&zone->subnets);
struct fw3_address *addr, *tmp;
struct list_head *addrs, *all;
- all = malloc(sizeof(*all));
-
+ all = calloc(1, sizeof(*all));
if (!all)
return NULL;
- memset(all, 0, sizeof(*all));
INIT_LIST_HEAD(all);
list_for_each_entry(net, &zone->networks, list)