Bug 80371 - mips/net/bpf_jit.c:1337: poor choice of variable type ?
Summary: mips/net/bpf_jit.c:1337: poor choice of variable type ?
Status: CLOSED CODE_FIX
Alias: None
Product: Platform Specific/Hardware
Classification: Unclassified
Component: MIPS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: ralf
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-16 17:13 UTC by David Binderman
Modified: 2015-07-09 22:47 UTC (History)
1 user (show)

See Also:
Kernel Version: 3.16-rc5
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description David Binderman 2014-07-16 17:13:57 UTC
[linux-3.16-rc5/arch/mips/net/bpf_jit.c:1337]: (style) Checking if unsigned variable 'off' is less than zero.

Source code is

            off = pkt_type_offset();

            if (off < 0)
                return -1;

but

    unsigned int i, off, load_order, condt;

and

static int pkt_type_offset(void)

Suggest put the return type from pkt_type_offset into a
signed variable, test that < 0, then use a cast to get the
value into an unsigned variable.

Something like

            signedVar = pkt_type_offset();

            if (signedVar < 0)
                return -1;
            off = (unsigned int) signedVar;
Comment 1 Andrey Utkin 2014-07-17 13:31:06 UTC
Thanks, patch submitted: https://patchwork.kernel.org/patch/4575021/
Comment 2 Andrey Utkin 2014-07-17 14:25:30 UTC
Resubmitted: https://patchwork.kernel.org/patch/4575881/
Comment 3 ralf 2015-07-09 22:47:24 UTC
Applied ages ago as 98fb24af5e6885ae5ae6b1598a875922e0d83a36 (arch/mips/net/bpf_jit.c: fix failure check)

Note You need to log in before you can comment on or make changes to this bug.