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]
Message-Id: <20091230132945.f32f49fd.akpm@linux-foundation.org>
Date:	Wed, 30 Dec 2009 13:29:45 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Heiko Carstens <heiko.carstens@...ibm.com>
Cc:	Ananth N Mavinakayanahalli <ananth@...ibm.com>,
	Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org
Subject: Re: kprobes: get rid of distinct type warning

On Mon, 21 Dec 2009 13:02:24 +0100
Heiko Carstens <heiko.carstens@...ibm.com> wrote:

> Of course the patch wouldn't help for CONFIG_PREEMPT and !CONFIG_SMP since
> we would have a comparison of a signed and and unsigned value again *sigh*.

We should fix that, shouldn't we?  Rather than working around it at one
caller site.

: #if NR_CPUS > 1
: #define num_online_cpus()	cpumask_weight(cpu_online_mask)
: #define num_possible_cpus()	cpumask_weight(cpu_possible_mask)
: #define num_present_cpus()	cpumask_weight(cpu_present_mask)
: #define num_active_cpus()	cpumask_weight(cpu_active_mask)
: #define cpu_online(cpu)		cpumask_test_cpu((cpu), cpu_online_mask)
: #define cpu_possible(cpu)	cpumask_test_cpu((cpu), cpu_possible_mask)
: #define cpu_present(cpu)	cpumask_test_cpu((cpu), cpu_present_mask)
: #define cpu_active(cpu)		cpumask_test_cpu((cpu), cpu_active_mask)
: #else
: #define num_online_cpus()	1
: #define num_possible_cpus()	1
: #define num_present_cpus()	1
: #define num_active_cpus()	1
: #define cpu_online(cpu)		((cpu) == 0)
: #define cpu_possible(cpu)	((cpu) == 0)
: #define cpu_present(cpu)	((cpu) == 0)
: #define cpu_active(cpu)		((cpu) == 0)
: #endif

The num_*() "functions" return unsigned on SMP and int on UP.  This is
wrong.

The cpu_*() "functions" got lucky and return int in both cases.

Personally I think it's neatest if a quantity which can never be
negative is held in an unsigned type.  Than includes anything starting
with "num".  But for expediency's sake we could live with making these
things consistently return "int".

Alas, changing those four num_*() "functions" to return int on SMP is a
pretty wide-reaching change and will probably expose warts.

--
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