Bug 76741

Summary: lib/lockdep/preload.c:95: possible bad test ?
Product: Tools Reporter: David Binderman (dcb314)
Component: OtherAssignee: Tools.Other (tools_other)
Status: RESOLVED CODE_FIX    
Severity: normal CC: andrey_utkin, jarrocha27, redsoxfantom
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.15-rc5 Subsystem:
Regression: No Bisected commit-id:

Description David Binderman 2014-05-22 16:15:29 UTC
[linux-3.15-rc5/tools/lib/lockdep/preload.c:95]: (warning) Comparison of a boolean expression with an integer other than 0 or 1.

Source code is

enum { none, prepare, done, } __init_state;
static void init_preload(void);
static void try_init_preload(void)
{
    if (!__init_state != done)
        init_preload();
}

Confusing double negative.

Comparison of a boolean value (!__init_state) with a value of 2 (done)
is unlikely to succeed.

Suggest code rework.
Comment 1 Andrey Utkin 2014-07-07 11:28:58 UTC
Looking at behaviour of init_preload(), which returns early if __init_state == done, i think that try_init_preload() can be dropped and replaced with just init_preload() where it was used.
Comment 2 Jaime Arrocha 2014-10-20 19:40:22 UTC
This has been fixed on the latest release of the kernel or as of 3.17.0.

The function was changed to,

static void try_init_preload(void)
{
	if (__init_state != done)
		init_preload();
}

I am new in this forum. How do I know if this kind of bugs have been fixed? Checking the mailing list archives?
Comment 3 Jean Delvare 2014-10-23 13:29:48 UTC
Bugzilla is a bug tracker, not a forum.