From: Denis Ovsienko Date: Mon, 25 Jan 2021 12:51:54 +0000 (+0000) Subject: OpenFlow 1.0: Simplify the snapend management. [skip ci] X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/6c982c49c695e958f6e881874b7ba1cc447588a0?ds=sidebyside OpenFlow 1.0: Simplify the snapend management. [skip ci] As Guy explains it, nd_push_snapend() makes it easy to save and to restore the snapend from different functions or different invocations of the same function. In a simple case a local variable and ND_MIN() do the job just as well without the associated memory management and error checking. --- diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c index 7751f2d9..82a4f0ba 100644 --- a/print-openflow-1.0.c +++ b/print-openflow-1.0.c @@ -1025,11 +1025,10 @@ of10_packet_data_print(netdissect_options *ndo, * what ether_print() needs to decode an Ethernet frame nested in * the middle of a TCP payload. */ - if (!nd_push_snapend(ndo, cp + len)) - (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, - "%s: failed to adjust snapend", __func__); + const u_char *snapend_save = ndo->ndo_snapend; + ndo->ndo_snapend = ND_MIN(cp + len, ndo->ndo_snapend); ether_print(ndo, cp, len, ND_BYTES_AVAILABLE_AFTER(cp), NULL, NULL); - nd_pop_packet_info(ndo); + ndo->ndo_snapend = snapend_save; ndo->ndo_vflag += 3; }