Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/npf/npfctl npfctl: switch to efun(3) routines.
details: https://anonhg.NetBSD.org/src/rev/05c0d6542983
branches: trunk
changeset: 782554:05c0d6542983
user: rmind <rmind%NetBSD.org@localhost>
date: Mon Nov 05 23:47:12 2012 +0000
description:
npfctl: switch to efun(3) routines.
diffstat:
usr.sbin/npf/npfctl/npf_disassemble.c | 10 ++---
usr.sbin/npf/npfctl/npf_extmod.c | 8 ++--
usr.sbin/npf/npfctl/npf_ncgen.c | 10 +++---
usr.sbin/npf/npfctl/npf_parse.y | 12 +++---
usr.sbin/npf/npfctl/npf_scan.l | 20 ++++++------
usr.sbin/npf/npfctl/npf_var.c | 12 +++---
usr.sbin/npf/npfctl/npfctl.c | 58 +++-------------------------------
usr.sbin/npf/npfctl/npfctl.h | 7 +---
8 files changed, 42 insertions(+), 95 deletions(-)
diffs (truncated from 414 to 300 lines):
diff -r ce7b6802ce1a -r 05c0d6542983 usr.sbin/npf/npfctl/npf_disassemble.c
--- a/usr.sbin/npf/npfctl/npf_disassemble.c Mon Nov 05 23:09:40 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_disassemble.c Mon Nov 05 23:47:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_disassemble.c,v 1.10 2012/10/29 02:27:12 rmind Exp $ */
+/* $NetBSD: npf_disassemble.c,v 1.11 2012/11/05 23:47:12 rmind Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
* FIXME: config generation should be redesigned..
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_disassemble.c,v 1.10 2012/10/29 02:27:12 rmind Exp $");
+__RCSID("$NetBSD: npf_disassemble.c,v 1.11 2012/11/05 23:47:12 rmind Exp $");
#include <stdio.h>
#include <stdlib.h>
@@ -48,8 +48,6 @@
#include <netinet/tcp.h>
#include <net/if.h>
-#include <util.h>
-
#define NPF_OPCODES_STRINGS
#include <net/npf_ncode.h>
@@ -108,7 +106,7 @@
/* Grow array, if needed, and add a new target. */
if (ni->ni_targidx == ni->ni_targsize) {
ni->ni_targsize += 16;
- ni->ni_targs = xrealloc(ni->ni_targs,
+ ni->ni_targs = erealloc(ni->ni_targs,
ni->ni_targsize * sizeof(uint32_t));
}
assert(ni->ni_targidx < ni->ni_targsize);
@@ -372,7 +370,7 @@
nc_inf_t *
npfctl_ncode_disinf(FILE *fp)
{
- nc_inf_t *ni = zalloc(sizeof(nc_inf_t));
+ nc_inf_t *ni = emalloc(sizeof(nc_inf_t));
memset(ni, 0, sizeof(nc_inf_t));
ni->ni_fp = fp;
diff -r ce7b6802ce1a -r 05c0d6542983 usr.sbin/npf/npfctl/npf_extmod.c
--- a/usr.sbin/npf/npfctl/npf_extmod.c Mon Nov 05 23:09:40 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_extmod.c Mon Nov 05 23:47:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_extmod.c,v 1.1 2012/09/16 13:47:41 rmind Exp $ */
+/* $NetBSD: npf_extmod.c,v 1.2 2012/11/05 23:47:12 rmind Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_extmod.c,v 1.1 2012/09/16 13:47:41 rmind Exp $");
+__RCSID("$NetBSD: npf_extmod.c,v 1.2 2012/11/05 23:47:12 rmind Exp $");
#include <stdlib.h>
#include <inttypes.h>
@@ -81,8 +81,8 @@
errx(EXIT_FAILURE, "dlopen: %s", dlerror());
}
- ext = zalloc(sizeof(npf_extmod_t));
- ext->name = xstrdup(name);
+ ext = emalloc(sizeof(npf_extmod_t));
+ ext->name = estrdup(name);
ext->init = npf_extmod_sym(handle, name, "init");
ext->cons = npf_extmod_sym(handle, name, "construct");
ext->param = npf_extmod_sym(handle, name, "param");
diff -r ce7b6802ce1a -r 05c0d6542983 usr.sbin/npf/npfctl/npf_ncgen.c
--- a/usr.sbin/npf/npfctl/npf_ncgen.c Mon Nov 05 23:09:40 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_ncgen.c Mon Nov 05 23:47:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_ncgen.c,v 1.13 2012/07/19 21:52:29 spz Exp $ */
+/* $NetBSD: npf_ncgen.c,v 1.14 2012/11/05 23:47:12 rmind Exp $ */
/*-
* Copyright (c) 2009-2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_ncgen.c,v 1.13 2012/07/19 21:52:29 spz Exp $");
+__RCSID("$NetBSD: npf_ncgen.c,v 1.14 2012/11/05 23:47:12 rmind Exp $");
#include <stdlib.h>
#include <stddef.h>
@@ -91,7 +91,7 @@
/* Otherwise, re-allocate the buffer and update the pointers. */
ctx->nc_len = NC_ALLOC_ROUND(reqlen);
- ctx->nc_buf = xrealloc(ctx->nc_buf, ctx->nc_len);
+ ctx->nc_buf = erealloc(ctx->nc_buf, ctx->nc_len);
ctx->nc_iptr = (uint8_t *)ctx->nc_buf + offset;
return ctx->nc_iptr;
}
@@ -126,7 +126,7 @@
reqlen = NC_ALLOC_ROUND(ctx->nc_jmp_it * sizeof(ptrdiff_t));
if (reqlen > NC_ALLOC_ROUND(ctx->nc_jmp_len)) {
- ctx->nc_jmp_list = xrealloc(ctx->nc_jmp_list, reqlen);
+ ctx->nc_jmp_list = erealloc(ctx->nc_jmp_list, reqlen);
ctx->nc_jmp_len = reqlen;
}
@@ -145,7 +145,7 @@
nc_ctx_t *
npfctl_ncgen_create(void)
{
- return zalloc(sizeof(nc_ctx_t));
+ return emalloc(sizeof(nc_ctx_t));
}
/*
diff -r ce7b6802ce1a -r 05c0d6542983 usr.sbin/npf/npfctl/npf_parse.y
--- a/usr.sbin/npf/npfctl/npf_parse.y Mon Nov 05 23:09:40 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_parse.y Mon Nov 05 23:47:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_parse.y,v 1.14 2012/10/02 23:38:52 rmind Exp $ */
+/* $NetBSD: npf_parse.y,v 1.15 2012/11/05 23:47:12 rmind Exp $ */
/*-
* Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
extern int yyleng;
extern char *yytext;
- char *msg, *context = xstrndup(yytext, yyleng);
+ char *msg, *context = estrndup(yytext, yyleng);
bool eol = (*context == '\n');
va_list ap;
@@ -66,7 +66,7 @@
yylineno - (int)eol, yycolumn, msg);
if (!eol) {
size_t len = strlen(context);
- char *dst = zalloc(len * 4 + 1);
+ char *dst = emalloc(len * 4 + 1);
strvisx(dst, context, len, VIS_WHITE|VIS_CSTYLE);
fprintf(stderr, " near '%s'", dst);
@@ -315,7 +315,7 @@
{
proc_call_t pc;
- pc.pc_name = xstrdup($1);
+ pc.pc_name = estrdup($1);
pc.pc_opts = $3;
$$ = npfvar_create(".proc_call");
npfvar_add_element($$, NPFVAR_PROC, &pc, sizeof(pc));
@@ -338,8 +338,8 @@
{
proc_param_t pp;
- pp.pp_param = xstrdup($1);
- pp.pp_value = $2 ? xstrdup($2) : NULL;
+ pp.pp_param = estrdup($1);
+ pp.pp_value = $2 ? estrdup($2) : NULL;
$$ = npfvar_create(".proc_param");
npfvar_add_element($$, NPFVAR_PROC_PARAM, &pp, sizeof(pp));
}
diff -r ce7b6802ce1a -r 05c0d6542983 usr.sbin/npf/npfctl/npf_scan.l
--- a/usr.sbin/npf/npfctl/npf_scan.l Mon Nov 05 23:09:40 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_scan.l Mon Nov 05 23:47:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_scan.l,v 1.6 2012/09/16 13:47:41 rmind Exp $ */
+/* $NetBSD: npf_scan.l,v 1.7 2012/11/05 23:47:12 rmind Exp $ */
/*-
* Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
@@ -109,7 +109,7 @@
"=" return EQ;
"0x"[0-9a-fA-F]+ {
- char *endp, *buf = zalloc(yyleng + 1);
+ char *endp, *buf = emalloc(yyleng + 1);
buf[yyleng] = 0;
yylval.num = strtoul(buf+2, &endp, 16);
free(buf);
@@ -117,46 +117,46 @@
}
{NUMBER}"."{NUMBER} {
- char *endp, *buf = xstrndup(yytext, yyleng);
+ char *endp, *buf = estrndup(yytext, yyleng);
yylval.fpnum = strtod(buf, &endp);
free(buf);
return FPNUM;
}
[0-9a-fA-F]+":"[0-9a-fA-F:]* {
- yylval.str = xstrndup(yytext, yyleng);
+ yylval.str = estrndup(yytext, yyleng);
return IPV6ADDR;
}
{NUMBER}"."[0-9][0-9.]* {
- yylval.str = xstrndup(yytext, yyleng);
+ yylval.str = estrndup(yytext, yyleng);
return IPV4ADDR;
}
{NUMBER} {
- char *endp, *buf = xstrndup(yytext, yyleng);
+ char *endp, *buf = estrndup(yytext, yyleng);
yylval.num = strtoul(buf, &endp, 10);
free(buf);
return NUM;
}
"<"{NID}">" {
- yylval.str = xstrndup(yytext + 1, yyleng - 2);
+ yylval.str = estrndup(yytext + 1, yyleng - 2);
return TABLE_ID;
}
"$"{NID} {
- yylval.str = xstrndup(yytext + 1, yyleng - 1);
+ yylval.str = estrndup(yytext + 1, yyleng - 1);
return VAR_ID;
}
{ID} {
- yylval.str = xstrndup(yytext, yyleng);
+ yylval.str = estrndup(yytext, yyleng);
return IDENTIFIER;
}
\"[^\"]*\" {
- yylval.str = xstrndup(yytext + 1, yyleng - 2);
+ yylval.str = estrndup(yytext + 1, yyleng - 2);
return STRING;
}
diff -r ce7b6802ce1a -r 05c0d6542983 usr.sbin/npf/npfctl/npf_var.c
--- a/usr.sbin/npf/npfctl/npf_var.c Mon Nov 05 23:09:40 2012 +0000
+++ b/usr.sbin/npf/npfctl/npf_var.c Mon Nov 05 23:47:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_var.c,v 1.5 2012/05/30 21:30:07 rmind Exp $ */
+/* $NetBSD: npf_var.c,v 1.6 2012/11/05 23:47:12 rmind Exp $ */
/*-
* Copyright (c) 2011-2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npf_var.c,v 1.5 2012/05/30 21:30:07 rmind Exp $");
+__RCSID("$NetBSD: npf_var.c,v 1.6 2012/11/05 23:47:12 rmind Exp $");
#include <stdlib.h>
#include <string.h>
@@ -60,8 +60,8 @@
npfvar_t *
npfvar_create(const char *name)
{
- npfvar_t *vp = zalloc(sizeof(*vp));
- vp->v_key = xstrdup(name);
+ npfvar_t *vp = emalloc(sizeof(*vp));
+ vp->v_key = estrdup(name);
var_num++;
return vp;
}
@@ -104,8 +104,8 @@
return NULL;
}
vp->v_count++;
- el = zalloc(sizeof(*el));
- el->e_data = zalloc(len);
+ el = emalloc(sizeof(*el));
+ el->e_data = emalloc(len);
el->e_type = type;
memcpy(el->e_data, data, len);
diff -r ce7b6802ce1a -r 05c0d6542983 usr.sbin/npf/npfctl/npfctl.c
--- a/usr.sbin/npf/npfctl/npfctl.c Mon Nov 05 23:09:40 2012 +0000
+++ b/usr.sbin/npf/npfctl/npfctl.c Mon Nov 05 23:47:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npfctl.c,v 1.22 2012/10/31 08:54:39 martin Exp $ */
+/* $NetBSD: npfctl.c,v 1.23 2012/11/05 23:47:12 rmind Exp $ */
/*-
* Copyright (c) 2009-2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npfctl.c,v 1.22 2012/10/31 08:54:39 martin Exp $");
+__RCSID("$NetBSD: npfctl.c,v 1.23 2012/11/05 23:47:12 rmind Exp $");
#include <sys/ioctl.h>
#include <sys/stat.h>
@@ -44,8 +44,6 @@
#include <unistd.h>
#include <errno.h>
Home |
Main Index |
Thread Index |
Old Index