From: Guy Harris Date: Fri, 21 Feb 2025 06:33:57 +0000 (-0800) Subject: compiler: squelch a warning from MSVC. X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/5ff3c5ef26a8c5a9ef1c95f406d4a0a10430cbcb compiler: squelch a warning from MSVC. Cast the sum of SKF_AD_OFF and a metadata field offset to bpf_u_int32 before making it the k field of an instruction. SKF_AD_OFF is negative, as is the sum in question, so you have to cast it. --- diff --git a/gencode.c b/gencode.c index 275cda2e..d7318e03 100644 --- a/gencode.c +++ b/gencode.c @@ -9273,7 +9273,7 @@ gen_vlan_patch_vid_test(compiler_state_t *cstate, struct block *b_vid) unsigned cnt; s = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS); - s->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT; + s->s.k = (bpf_u_int32)(SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT); /* true -> next instructions, false -> beginning of b_vid */ sjeq = new_stmt(cstate, JMP(BPF_JEQ)); @@ -9282,7 +9282,7 @@ gen_vlan_patch_vid_test(compiler_state_t *cstate, struct block *b_vid) sappend(s, sjeq); s2 = new_stmt(cstate, BPF_LD|BPF_H|BPF_ABS); - s2->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG; + s2->s.k = (bpf_u_int32)(SKF_AD_OFF + SKF_AD_VLAN_TAG); sappend(s, s2); sjeq->s.jt = s2; @@ -9320,7 +9320,7 @@ gen_vlan_bpf_extensions(compiler_state_t *cstate, bpf_u_int32 vlan_num, /* generate new filter code based on extracting packet * metadata */ s = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS); - s->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT; + s->s.k = (bpf_u_int32)(SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT); b0 = new_block(cstate, JMP(BPF_JEQ)); b0->stmts = s;