lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 27 Apr 2015 16:25:01 +0200 (CEST)
From:	Jiri Kosina <jkosina@...e.cz>
To:	David Howells <dhowells@...hat.com>
cc:	linux-kernel@...r.kernel.org
Subject: Re: Compiler warning about comparing result of !!test_bit() to an
 integer

On Mon, 27 Apr 2015, David Howells wrote:

> Hi Jiri,
> 
> This line in hid-input.c:
> 
> 	if (usage->type == EV_KEY && !!test_bit(usage->code, input->key) != value)
> 		input_event(input, EV_MSC, MSC_SCAN, usage->hid);
> 
> gives:
> 
> ../drivers/hid/hid-input.c: In function 'hidinput_hid_event':
> ../drivers/hid/hid-input.c:1160:167: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
> 
> with gcc-5.1.  Given that 'value' doesn't appear to be a boolean, is this correct?

gcc-5 became somehow very picky about '!!' usages. I recall quite some 
internal discussions with our gcc guys, which resulted in upstream gcc 
bugzillas being filled about gcc warning in completely legitimate cases.

> 
> This was introduced by commit c01d50d181f074a60bf3ed54eb055ce1679afb98.

Gah, that was long time ago! :)

This is because we want to handle autorepeat (i.e. value 2) correctly. Now 
that you ask, it seems to me that we actually should be doing

	!!test_bit(usage->code, input->key) != !!value

to be really exact (i.e. so that we really can't have oscilating state).

I'll think about it a little bit more, and eventually probably fix it this 
way with your Reported-by: if you are OK with that.

Thanks,

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ