svn commit: r273910 - head/sys/netgraph
Gleb Smirnoff
glebius at FreeBSD.org
Fri Oct 31 16:00:46 UTC 2014
Author: glebius
Date: Fri Oct 31 16:00:45 2014
New Revision: 273910
URL: https://svnweb.freebsd.org/changeset/base/273910
Log:
Use macro ERROUT() to make code more laconic and follow style of other
netgraph code.
Submitted by: Dmitry Luhtionov <dmitryluhtionov gmail.com>
Modified:
head/sys/netgraph/ng_frame_relay.c
Modified: head/sys/netgraph/ng_frame_relay.c
==============================================================================
--- head/sys/netgraph/ng_frame_relay.c Fri Oct 31 15:23:24 2014 (r273909)
+++ head/sys/netgraph/ng_frame_relay.c Fri Oct 31 16:00:45 2014 (r273910)
@@ -148,6 +148,8 @@ static struct ng_type typestruct = {
};
NETGRAPH_INIT(framerelay, &typestruct);
+#define ERROUT(x) do { error = (x); goto done; } while (0)
+
/*
* Given a DLCI, return the index of the context table entry for it,
* Allocating a new one if needs be, or -1 if none available.
@@ -335,10 +337,8 @@ ngfrm_rcvdata(hook_p hook, item_p item)
char *data;
/* Data doesn't come in from just anywhere (e.g debug hook) */
- if (ctxp == NULL) {
- error = ENETDOWN;
- goto bad;
- }
+ if (ctxp == NULL)
+ ERROUT(ENETDOWN);
/* If coming from downstream, decode it to a channel */
dlci = ctxp->dlci;
@@ -351,20 +351,16 @@ ngfrm_rcvdata(hook_p hook, item_p item)
/* If there is no live channel, throw it away */
if ((sc->downstream.hook == NULL)
- || ((ctxp->flags & CHAN_ACTIVE) == 0)) {
- error = ENETDOWN;
- goto bad;
- }
+ || ((ctxp->flags & CHAN_ACTIVE) == 0))
+ ERROUT(ENETDOWN);
/* Store the DLCI on the front of the packet */
alen = sc->addrlen;
if (alen == 0)
alen = 2; /* default value for transmit */
M_PREPEND(m, alen, M_NOWAIT);
- if (m == NULL) {
- error = ENOBUFS;
- goto bad;
- }
+ if (m == NULL)
+ ERROUT(ENOBUFS);
data = mtod(m, char *);
/*
@@ -401,7 +397,7 @@ ngfrm_rcvdata(hook_p hook, item_p item)
NG_FWD_NEW_DATA(error, item, sc->downstream.hook, m);
return (error);
-bad:
+done:
NG_FREE_ITEM(item);
NG_FREE_M(m);
return (error);
@@ -422,10 +418,8 @@ ngfrm_decode(node_p node, item_p item)
struct mbuf *m;
NGI_GET_M(item, m);
- if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL) {
- error = ENOBUFS;
- goto out;
- }
+ if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL)
+ ERROUT(ENOBUFS);
data = mtod(m, char *);
if ((alen = sc->addrlen) == 0) {
sc->addrlen = alen = ngfrm_addrlen(data);
@@ -447,14 +441,11 @@ ngfrm_decode(node_p node, item_p item)
SHIFTIN(makeup + 3, data[3], dlci);
break;
default:
- error = EINVAL;
- goto out;
+ ERROUT(EINVAL);
}
- if (dlci > 1023) {
- error = EINVAL;
- goto out;
- }
+ if (dlci > 1023)
+ ERROUT(EINVAL);
ctxnum = sc->ALT[dlci];
if ((ctxnum & CTX_VALID) && sc->channel[ctxnum &= CTX_VALUE].hook) {
/* Send it */
@@ -464,7 +455,7 @@ ngfrm_decode(node_p node, item_p item)
} else {
error = ENETDOWN;
}
-out:
+done:
NG_FREE_ITEM(item);
NG_FREE_M(m);
return (error);
More information about the svn-src-head
mailing list