warnings

Dave Jones davej at redhat.com
Mon Sep 6 12:34:59 PDT 2004


On Mon, Sep 06, 2004 at 11:30:31AM -0600, Ray Lehtiniemi wrote:
 > On Fri, Sep 03, 2004 at 05:47:40PM +0100, Dave Jones wrote:
 > >  > 
 > >  > are these just snapshots of http://sparse.bkbits.net/, or snapshots
 > >  > with your local changes as well?
 > > 
 > > Just of Linus' tree.  I can make snapshots of my changes too if
 > > theres any interest in doing that.
 > 
 > what sort of changes are you making locally?  if it's anything that
 > is required to get sparse working on the xorg codebase, then i'd
 > probably be interested in working from your sparse bk tree, or
 > periodic snapshots of it.

I did have a bunch of stuff that reduced warnings a lot,
(it didn't handle __const amongst other things for eg).

I just did a resync, and now that his tree handles #include_next too,
there's only one more local difference in my tree, and thats the cgcc
script. My version below has __*_MAX support (x86-only, but trivial
to support on other arch's), which also reduced the warning count
by a huge amount.

thanks,

		Dave

#!/usr/bin/perl -w
# -----------------------------------------------------------------------------

my $cc = $ENV{'REAL_CC'} || 'cc';
my $arch = `uname -m | sed -e s/i.86/x86/ | sed s/athlon/x86/`;
chomp $arch;
my $checkargs = "";

if ($arch eq 'x86') {
	$checkargs .= '-D__SCHAR_MAX__=127 ';
	$checkargs .= '-D__SHRT_MAX__=32767 ';
	$checkargs .= '-D__INT_MAX__=2147483647 ';
	$checkargs .= '-D__LONG_MAX__=2147483647 ';
};

my $check = $ENV{'CHECK'} || 'sparse';

$check .= " $checkargs";


my $seen_a_c_file = 0;
foreach (@ARGV) {
    # Look for a .c file.  We don't want to run the checker on .o or .so files
    # in the link run.  (This simplistic check knows nothing about options
    # with arguments, but it seems to do the job.)
    $seen_a_c_file = 1 if /^[^-].*\.c/;

    my $this_arg = ' ' . &quote_arg ($_);
    $cc .= $this_arg unless &check_only_option ($_);
    $check .= $this_arg;
}

system ($check) if $seen_a_c_file;
exec ($cc);

# -----------------------------------------------------------------------------
# Check if an option is for "check" only.

sub check_only_option {
    my ($arg) = @_;
    return 1 if $arg =~ /^-W(no-?)?default-bitfield-sign$/;
    return 0;
}

# -----------------------------------------------------------------------------
# Simple arg-quoting function.  Just adds backslashes when needed.

sub quote_arg {
    my ($arg) = @_;
    return "''" if $arg eq '';
    return join ('',
		 map {
		     m|^[-a-zA-Z0-9._/,=]+$| ? $_ : "\\" . $_;
		 } (split (//, $arg)));
}

# -----------------------------------------------------------------------------



More information about the xorg mailing list