From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bernd Petrovitsch Subject: Re: including sparse headers in C++ code Date: Wed, 20 Oct 2010 12:19:02 +0200 Message-ID: <1287569942.7542.8.camel@thorin> References: <20101011224656.GN19804@ZenIV.linux.org.uk> <20101016191153.GA19324@feather> <20101018053955.GA1628@feather> <20101019213109.GV19804@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from esgaroth.petrovitsch.at ([78.47.184.11]:2226 "EHLO esgaroth.petrovitsch.priv.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751251Ab0JTKTL (ORCPT ); Wed, 20 Oct 2010 06:19:11 -0400 In-Reply-To: Sender: linux-sparse-owner@vger.kernel.org List-Id: linux-sparse@vger.kernel.org To: Tomas Klacko Cc: Al Viro , Christopher Li , Josh Triplett , linux-sparse@vger.kernel.org On Mit, 2010-10-20 at 00:49 +0200, Tomas Klacko wrote: > On Tue, Oct 19, 2010 at 11:31 PM, Al Viro wrote: > > On Tue, Oct 19, 2010 at 10:03:42PM +0200, Tomas Klacko wrote: > > >> static inline int match_op(struct token *token, int op) > >> { > >> - return token->pos.type == TOKEN_SPECIAL && token->special == op; > >> + return token->pos.type == TOKEN_SPECIAL && token->special == (unsigned int)op; > > > > What was that one for? > > "warning: comparison between signed and unsigned integer expressions" Add "-Wsign-compare" to the CFLAGS (for a pure C compile) and you will find many more of them. IMHO it needs a decision if the goal is to prefer signed or unsigned int (where no negative values ever used/assigned) and convert struct members and/or global variables. Most of them TTBOMK are never negative anyways. For the "C vs C++" issue: if you have an enum, the rules (or at least the reality defined by gcc) are subtly different if it's a signed int or an unsigned int and the values of their members. Bernd -- mobile: +43 664 4416156 http://www.sysprog.at/ Linux Software Development, Consulting and Services