X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=netlink.c;h=75763cf520719fc1bfc2934da725344121c35aa0;hp=e197e80f8c69508f5f617d9af86b1bfa07957098;hb=bfc34affaf5e80fe6a85bbcc4c302005154b4531;hpb=322a0105bc70230236732e9751d0c888f37a5072 diff --git a/netlink.c b/netlink.c index e197e80..75763cf 100644 --- a/netlink.c +++ b/netlink.c @@ -386,7 +386,7 @@ static uint16_t netlink_icmp_reply_len(struct buffer_if *buf) /* We include the first 8 bytes of the packet data, provided they exist */ hlen+=8; plen=ntohs(iph->tot_len); - return (hlen>plen?plen:hlen); + return MIN(hlen,plen); } /* client indicates where the packet we're constructing a response to @@ -1039,8 +1039,7 @@ static void netlink_phase_hook(void *sst, uint32_t new_phase) /* All the networks serviced by the various tunnels should now * have been registered. We build a routing table by sorting the * clients by priority. */ - st->routes=safe_malloc_ary(sizeof(*st->routes),st->n_clients, - "netlink_phase_hook"); + NEW_ARY(st->routes,st->n_clients); /* Fill the table */ i=0; for (c=st->clients; c; c=c->next) { @@ -1138,7 +1137,7 @@ static closure_t *netlink_inst_create(struct netlink *st, return NULL; } - c=safe_malloc(sizeof(*c),"netlink_inst_create"); + NEW(c); c->cl.description=name; c->cl.type=CL_NETLINK; c->cl.apply=NULL; @@ -1307,7 +1306,7 @@ static list_t *null_apply(closure_t *self, struct cloc loc, dict_t *context, item_t *item; dict_t *dict; - st=safe_malloc(sizeof(*st),"null_apply"); + NEW(st); item=list_elem(args,0); if (!item || item->type!=t_dict)