linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christopher Li <sparse@chrisli.org>
To: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Cc: Sparse Mailing-list <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH 4/5] Fix some "plain integer as NULL pointer" warnings on cygwin
Date: Mon, 20 Jul 2009 13:31:20 -0700	[thread overview]
Message-ID: <70318cbf0907201331v1c830779i89c9bef9d6706115@mail.gmail.com> (raw)
In-Reply-To: <4A623766.5020002@ramsay1.demon.co.uk>

On Sat, Jul 18, 2009 at 1:58 PM, Ramsay Jones<ramsay@ramsay1.demon.co.uk> wrote:
>
> These sparse warnings are caused by broken new-lib headers,
> which sometimes result in NULL being defined as 0, and at
> other times defined as ((void *)0).
>
> In essence, the only header which works correctly (by defining
> NULL as ((void *)0)) is stddef.h. The stdio.h and time.h headers
> also work, almost by accident, by indirectly including stddef.h.
> The other standard headers which are required to define the NULL
> macro, namely locale.h, stdlib.h, string.h and wchar.h, all
> define the macro as the 0 token. (This is a slightly simplified
> description of the problem).
>
> In order to suppress these warnings, include the stddef.h header
> at the start of ptrlist.c.
>
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> ---
>
> Hi Chris,
>
> $ cat -n null-test.sh
>     1  #!/bin/bash
>     2
>     3  # The C99 standard says that the following headers define NULL:
>     4  #   locale.h (7.11), stddef.h (7.17), stdio.h (7.19.1),
>     5  #   stdlib.h (7.20), string.h (7.21.1), time.h (7.23.1),
>     6  #   wchar.h (7.24.1).
>     7
>     8  for i in locale.h stddef.h stdio.h stdlib.h string.h time.h wchar.h
>     9  do
>    10          printf "%10s:  " $i
>    11          printf "#include<%s>\nchar *xyz_ptr = NULL;\n" $i >t.c
>    12          cgcc -E t.c | grep xyz_ptr
>    13  done
>    14  rm t.c
>    15
> $ ./null-test.sh

That is what I get in FC11:
  locale.h:  char *xyz_ptr = ((void *)0);
  stddef.h:  char *xyz_ptr = ((void *)0);
   stdio.h:  char *xyz_ptr = ((void *)0);
  stdlib.h:  char *xyz_ptr = ((void *)0);
  string.h:  char *xyz_ptr = ((void *)0);
    time.h:  char *xyz_ptr = ((void *)0);
   wchar.h:  char *xyz_ptr = ((void *)0);

Which system has this problem?

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-07-20 20:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-18 20:58 [PATCH 4/5] Fix some "plain integer as NULL pointer" warnings on cygwin Ramsay Jones
2009-07-20 20:31 ` Christopher Li [this message]
2009-07-21 21:54   ` Ramsay Jones
2009-07-22  0:37     ` Christopher Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70318cbf0907201331v1c830779i89c9bef9d6706115@mail.gmail.com \
    --to=sparse@chrisli.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=ramsay@ramsay1.demon.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).