Bug 44131 - i7300_edac.c: 2 * bad macro test
Summary: i7300_edac.c: 2 * bad macro test
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: EDAC (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Mauro Carvalho Chehab
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-02 20:29 UTC by David Binderman
Modified: 2012-12-15 10:20 UTC (History)
2 users (show)

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


Attachments
i7300_edac: Fix error flag testing (2.49 KB, patch)
2012-10-18 13:57 UTC, Jean Delvare
Details | Diff

Description David Binderman 2012-07-02 20:29:17 UTC
I just ran the static analyser cppcheck over the source code of the
linux kernel version 3.5-rc5.

It said

[linux-3.5-rc5/drivers/edac/i7300_edac.c:449]: (style) Expression '(X & 0x30000000) == 0x2' is always false
[linux-3.5-rc5/drivers/edac/i7300_edac.c:485]: (style) Expression '(X & 0x30000000) == 0x2' is always false

The source codes are

        branch = (GET_FBD_FAT_IDX(error_reg) == 2) ? 1 : 0;

and
        branch = (GET_FBD_FAT_IDX(error_reg) == 2) ? 1 : 0;

but

#define GET_FBD_FAT_IDX(fbderr) (fbderr & (3 << 28))

so I agree with the analyser. Suggest code rework.
Comment 1 Jean Delvare 2012-10-18 13:56:51 UTC
Good catch, thanks for reporting.
Comment 2 Jean Delvare 2012-10-18 13:57:41 UTC
Created attachment 83851 [details]
i7300_edac: Fix error flag testing

Candidate fix, needs review and testing.
Comment 3 Florian Mickler 2012-12-15 03:31:05 UTC
A patch referencing this bug report has been merged in Linux v3.7-rc8:

commit 7e06b7a3333f5c7a0cec12aff20d39c5c87c0795
Author: Jean Delvare <jdelvare@suse.de>
Date:   Thu Oct 18 15:54:45 2012 +0200

    i7300_edac: Fix error flag testing

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