summaryrefslogtreecommitdiff
path: root/addrtoname.h
diff options
context:
space:
mode:
authorDenis Ovsienko <denis@ovsienko.info>2020-09-16 23:46:20 +0100
committerDenis Ovsienko <denis@ovsienko.info>2020-09-17 15:01:25 +0100
commit729a57f75a9c97fecc9ba5b4d7762dd89c797748 (patch)
tree75ad6f1b9ab05e6727d566fbf8d2772376f1c1b1 /addrtoname.h
parent503c7d1dc16961fdd8a3f62aea688cab270328e9 (diff)
downloadtcpdump-729a57f75a9c97fecc9ba5b4d7762dd89c797748.tar.gz
Introduce and use nd_trunc(). [skip ci]
This new function is a part of item 2 of the longjmp() conversion plan Francois-Xavier proposed on tcpdump-workers. As a noreturn function, it can fit uniformly at the end of any decoder function, regardless if void or not, for example: const u_char * something_print (netdissect_options *ndo, const u_char *cp, u_int len) { /* (some normal decoding) */ ND_TCHECK_2(cp); /* (some more normal decoding) */ return cp + len; trunc: nd_trunc(ndo); /* The compiler does not warn about a missing return. */ }
Diffstat (limited to 'addrtoname.h')
-rw-r--r--addrtoname.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/addrtoname.h b/addrtoname.h
index 8a262aa7..b50739f3 100644
--- a/addrtoname.h
+++ b/addrtoname.h
@@ -68,7 +68,7 @@ get_linkaddr_string(netdissect_options *ndo, const uint8_t *p,
const unsigned int type, const unsigned int len)
{
if (!ND_TTEST_LEN(p, len))
- longjmp(ndo->ndo_truncated, 1);
+ nd_trunc(ndo);
return linkaddr_string(ndo, p, type, len);
}
@@ -76,7 +76,7 @@ static inline const char *
get_etheraddr_string(netdissect_options *ndo, const uint8_t *p)
{
if (!ND_TTEST_LEN(p, MAC_ADDR_LEN))
- longjmp(ndo->ndo_truncated, 1);
+ nd_trunc(ndo);
return etheraddr_string(ndo, p);
}
@@ -84,7 +84,7 @@ static inline const char *
get_le64addr_string(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_8(p))
- longjmp(ndo->ndo_truncated, 1);
+ nd_trunc(ndo);
return le64addr_string(ndo, p);
}
@@ -93,7 +93,7 @@ get_isonsap_string(netdissect_options *ndo, const uint8_t *nsap,
u_int nsap_length)
{
if (!ND_TTEST_LEN(nsap, nsap_length))
- longjmp(ndo->ndo_truncated, 1);
+ nd_trunc(ndo);
return isonsap_string(ndo, nsap, nsap_length);
}
@@ -101,7 +101,7 @@ static inline const char *
get_ipaddr_string(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_4(p))
- longjmp(ndo->ndo_truncated, 1);
+ nd_trunc(ndo);
return ipaddr_string(ndo, p);
}
@@ -109,7 +109,7 @@ static inline const char *
get_ip6addr_string(netdissect_options *ndo, const u_char *p)
{
if (!ND_TTEST_16(p))
- longjmp(ndo->ndo_truncated, 1);
+ nd_trunc(ndo);
return ip6addr_string(ndo, p);
}