From: Victor Julien Date: Thu, 4 Nov 2021 06:52:59 +0000 (+0100) Subject: af-packet: PacketSetData can't fail; remove check X-Git-Tag: suricata-7.0.0-beta1~1242 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cbfcce0ac01a786f5ae4c2935eeb4970e773889;p=thirdparty%2Fsuricata.git af-packet: PacketSetData can't fail; remove check PacketSetData() can't fail unless the input pointer is NULL, which is impossible from the af-packet paths calling it. Remove error check to avoid possible branching. --- diff --git a/src/source-af-packet.c b/src/source-af-packet.c index e7c645c8b3..e6a214bfc1 100644 --- a/src/source-af-packet.c +++ b/src/source-af-packet.c @@ -949,9 +949,7 @@ static bool AFPReadFromRingSetupPacket( p->vlan_idx = 1; } - if (PacketSetData(p, (unsigned char *)h.raw + h.h2->tp_mac, h.h2->tp_snaplen) == -1) { - return false; - } + (void)PacketSetData(p, (unsigned char *)h.raw + h.h2->tp_mac, h.h2->tp_snaplen); p->afp_v.relptr = h.raw; p->ReleasePacket = AFPReleasePacket; @@ -1122,10 +1120,8 @@ static inline int AFPParsePacketV3(AFPThreadVars *ptv, struct tpacket_block_desc p->vlan_idx = 1; } - if (PacketSetData(p, (unsigned char *)ppd + ppd->tp_mac, ppd->tp_snaplen) == -1) { - TmqhOutputPacketpool(ptv->tv, p); - SCReturnInt(AFP_SURI_FAILURE); - } + (void)PacketSetData(p, (unsigned char *)ppd + ppd->tp_mac, ppd->tp_snaplen); + p->afp_v.relptr = ppd; p->ReleasePacket = AFPReleasePacketV3; p->afp_v.mpeer = ptv->mpeer;