Skip to content

Commit 5ff3c5e

Browse files
committed
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.
1 parent c115392 commit 5ff3c5e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

gencode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9273,7 +9273,7 @@ gen_vlan_patch_vid_test(compiler_state_t *cstate, struct block *b_vid)
92739273
unsigned cnt;
92749274

92759275
s = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
9276-
s->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT;
9276+
s->s.k = (bpf_u_int32)(SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT);
92779277

92789278
/* true -> next instructions, false -> beginning of b_vid */
92799279
sjeq = new_stmt(cstate, JMP(BPF_JEQ));
@@ -9282,7 +9282,7 @@ gen_vlan_patch_vid_test(compiler_state_t *cstate, struct block *b_vid)
92829282
sappend(s, sjeq);
92839283

92849284
s2 = new_stmt(cstate, BPF_LD|BPF_H|BPF_ABS);
9285-
s2->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG;
9285+
s2->s.k = (bpf_u_int32)(SKF_AD_OFF + SKF_AD_VLAN_TAG);
92869286
sappend(s, s2);
92879287
sjeq->s.jt = s2;
92889288

@@ -9320,7 +9320,7 @@ gen_vlan_bpf_extensions(compiler_state_t *cstate, bpf_u_int32 vlan_num,
93209320
/* generate new filter code based on extracting packet
93219321
* metadata */
93229322
s = new_stmt(cstate, BPF_LD|BPF_B|BPF_ABS);
9323-
s->s.k = SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT;
9323+
s->s.k = (bpf_u_int32)(SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT);
93249324

93259325
b0 = new_block(cstate, JMP(BPF_JEQ));
93269326
b0->stmts = s;

0 commit comments

Comments
 (0)