[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: stdlib tweak
From: |
Bruno Haible |
Subject: |
Re: stdlib tweak |
Date: |
Wed, 23 Dec 2009 11:32:51 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Eric,
> > > in order to validate that a function is correctly declared when the user
> > > includes just the one header named in the standards. We can then fix the
> > > fallout by making the *.in.h headers pull in the necessary pre-requisites
> > > for
> > > functions that declared in the wrong system header.
Great work! I'm sure there will be some fallout...
> I went with signature_check.
I like it. And yes, we need to make it non-'static', like so many other stuff
in unit tests that we don't want gcc to warn about.
> diff --git a/tests/test-iconv.c b/tests/test-iconv.c
> index e7e5742..2e5db0f 100644
> --- a/tests/test-iconv.c
> +++ b/tests/test-iconv.c
> @@ -1,5 +1,5 @@
> /* Test of character set conversion.
> - Copyright (C) 2007-2008 Free Software Foundation, Inc.
> + Copyright (C) 2007-2009 Free Software Foundation, Inc.
>
> This program is free software: you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> @@ -20,6 +20,12 @@
>
> #if HAVE_ICONV
> # include <iconv.h>
> +
> +size_t (*signature_check1) (iconv_t, char **, size_t *, char **,
> + size_t *) = iconv;
On some systems, iconv is declared with 'const' in the first pointer argument
(which is logical - no idea why POSIX never got this right). You can change
this to
size_t (*signature_check1) (iconv_t, ICONV_CONST char **, size_t *, char **,
size_t *) = iconv;
The macro ICONV_CONST is defined through iconv.m4.
> diff --git a/tests/test-lstat.c b/tests/test-lstat.c
> index 8c62bc1..c471368 100644
> --- a/tests/test-lstat.c
> +++ b/tests/test-lstat.c
> @@ -20,6 +20,12 @@
>
> #include <sys/stat.h>
>
> +/* Caution: lstat may be a function-like macro. Although this
> + signature check must pass, it may be the signature of the real (and
> + broken) lstat rather than rpl_lstat. Most code should not use the
> + address of lstat. */
> +int (*signature_check) (char const *, struct stat *) = lstat;
This warning is justified for the 'stat' function. But lstat is correctly
redirected by gnulib. No need for this caution comment here.
> diff --git a/tests/test-nl_langinfo.c b/tests/test-nl_langinfo.c
> index 337e6ec..86d237f 100644
> --- a/tests/test-nl_langinfo.c
> +++ b/tests/test-nl_langinfo.c
> @@ -20,6 +20,8 @@
>
> #include <langinfo.h>
>
> +char *(*signature_check) (nl_item, locale_t) = nl_langinfo;
This is incorrect. nl_langinfo does not take a 'locale_t' argument.
You must be confusing it with nl_langinfo_l (which is not supported by
gnulib yet).
> diff --git a/tests/test-rename.c b/tests/test-rename.c
> index 0d51140..73805cc 100644
> --- a/tests/test-rename.c
> +++ b/tests/test-rename.c
> @@ -16,12 +16,13 @@
>
> #include <config.h>
>
> -#include <unistd.h>
> +#include <stdio.h>
> +
> +int (*signature_check) (char const *, char const *) = rename;
Yup. Right.
Bruno
- Re: ASSERT macro, (continued)
- Re: ASSERT macro, Bruno Haible, 2009/12/23
- Re: _GL_UNUSED macro, Bruno Haible, 2009/12/23
- new module 'unused-parameter', Bruno Haible, 2009/12/24
- Re: new module 'unused-parameter', Bruno Haible, 2009/12/25
- Re: new module 'unused-parameter', Jim Meyering, 2009/12/25
- Re: new module 'unused-parameter', Bruno Haible, 2009/12/25
- Re: new module 'unused-parameter', Simon Josefsson, 2009/12/27
- Re: new module 'unused-parameter', Simon Josefsson, 2009/12/29
- Re: new module 'unused-parameter', Jim Meyering, 2009/12/29
- Re: stdlib tweak, Jim Meyering, 2009/12/23
- Re: stdlib tweak,
Bruno Haible <=
- Re: stdlib tweak, Eric Blake, 2009/12/23
- Re: stdlib tweak, Eric Blake, 2009/12/23
- Re: ASSERT and SIGNATURE_CHECK macros, Bruno Haible, 2009/12/23
- Re: ASSERT and SIGNATURE_CHECK macros, Eric Blake, 2009/12/23
- Re: ASSERT and SIGNATURE_CHECK macros, Eric Blake, 2009/12/24
- Re: ASSERT and SIGNATURE_CHECK macros, Jim Meyering, 2009/12/24
- Re: SIGNATURE_CHECK, Bruno Haible, 2009/12/24
- Re: SIGNATURE_CHECK, Eric Blake, 2009/12/24
- Re: SIGNATURE_CHECK, Bruno Haible, 2009/12/24
- Re: SIGNATURE_CHECK, Eric Blake, 2009/12/24