bug-gnulib
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]