Re: autoconf-2.68: no AC_LANG_SOURCE call detected in body

2011-06-14 Thread Křištof Želechovski
Please observe that the following code from 3.1.2 The Autoconf Language is 
obsolete and should be updated:

AC_COMPILE_IFELSE([[char b[10];]], [], [AC_MSG_ERROR([you lose])])

Running this snippet through autoconf produces the warning:

no AC_LANG_SOURCE call detected in body

It seems the following syntax is required instead:

AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char b[10];]])], [], 
[AC_MSG_ERROR([you lose])])

Please fix,
Chris



Re: bug#8846: coreutils-8.12 on HP-UX 11.31: 3 of 365 tests failed

2011-06-14 Thread Stefano Lattarini
Notice: this is a JFTR answer; for the final solution of the issue, see
the better working solution at:
  http://lists.gnu.org/archive/html/bug-coreutils/2011-06/msg00080.html
  http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg00016.html

On Tuesday 14 June 2011, Eric Blake wrote:
 On 06/13/2011 04:24 PM, Stefano Lattarini wrote:
  On Monday 13 June 2011, Eric Blake wrote:
 
  Not possible to portably sniff out closed fds; quoting the autoconf manual:
 
  Don't rely on duplicating a closed file descriptor to cause an
  error.  With Solaris @command{/bin/sh}, when the redirection fails, the
  output goes to the original file descriptor.
 
  Do the shells with the close-on-exec issue also suffer of the issue with
  closed fds you've reported?  If not, the following could be enough to
  solve our situation without having to change automake:
 
 Where are you proposing this hack?  In init.sh (after fd 9 has already
 been closed if the calling shell used exec instead of some other form of
 redirection)?  That is, why are we trying to fix init.sh to deal with a
 closed fd after the fact, when it seems like the better approach is to
 guarantee that fd is never closed on exec in the first place?  Which
 necessarily implies altering the caller.
 
  
if (exec 3-; exec 43) /dev/null 21; then
  # Cannot determine whether a file descriptor is closed, fall back
  # to inferior hack.
  if test 2 -ne $stderr_fileno_  test ! -t $stderr_fileno_; then
eval exec $stderr_fileno_2 # Or is `stderr_fileno_=2' enough?
  fi
 
 Or is the whole point of this hack to init.sh to avoid the spurious
 warning about EBADF and to instead redirect errors to the
 (possibly-altered-by-make) fd 2 when fd 9 was lost, so that at least the
 warning messages appear in the logs even though we lost the chance to
 display them on the tty?

Yes, this was the idea.  But it is moot now that we have a better solution
to be used in TESTS_ENVRIRONMENT.

 At any rate, in answer to your question:
 
 Solaris /bin/sh (the shell where failed redirections are silently
 ignored) does this:
 
 $ /bin/sh -c '(exec 3-; exec 43) /dev/null 21; echo $?'
 0
 $ cat k
 #!/bin/sh
 e=9; warn_ () { echo $@ 1$e; }; warn_ x
 $ /bin/sh k
 x
 $ /bin/sh k /dev/null
 $ /bin/sh k 92
 x
 $ /bin/sh k 92 /dev/null
 x
 
 That is, if fd 9 is closed, then 1$e (aka 9) is a no-op on that
 shell, and output goes to the original fd 1; but if fd 9 is open, then
 output goes to fd 9.
 
 Whereas ksh and HP-UX sh are both vocal on failed redirections, for
 reliable detection:
 
 $ ksh -c '(exec 3-; exec 43) /dev/null 21; echo $?'
 1
 $ ksh k
 k[2]: 9: cannot open [Bad file number]
 $ ksh k /dev/null
 k[2]: 9: cannot open [Bad file number]
 $ ksh k 92
 x
 $ ksh k 92 /dev/null
 x
 
This would have been a problem :-/
Luckily, no more need to worry about it now :-)

Regards,
  Stefano



Re: bug#8846: coreutils-8.12 on HP-UX 11.31: 3 of 365 tests failed

2011-06-14 Thread Stefano Lattarini
[adding automake-patches on CC:]

Reference to original thread(s), mostly duplicated:
 http://lists.gnu.org/archive/html/bug-coreutils/2011-06/msg00051.html
 http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg2.html

Reference to last relevant message there:
 http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg00018.html
 http://lists.gnu.org/archive/html/bug-coreutils/2011-06/msg00082.html
 
On Tuesday 14 June 2011, Eric Blake wrote:
 On 06/13/2011 04:29 PM, Stefano Lattarini wrote:
  If this work, then using a bare `2' *at the end of TESTS_ENVIRONMENT* and
 
 You meant a bare `92',

Yes, sorry.

 but yes that does seem to be workable for what we want!
 
  *without a following semicolon* might give a portable workaround, as if I'm
  not mistaken POSIX mandates that redirections can be specified anywere on
  the command line, and are to be evaluated from left to right.
 
 Yes, all shells support these as equivalent:
 
 92 sh k
 sh k 92
 
  
  UPDATE: Yes, it seems to work.  I'll add a testcase to the 'maint' branch in
  case you and Jim decide to go with this solution (and you can confirm that 
  it
  really works).
 
 Cool!  Definitely worth documenting in the automake manual, as owner of
 TESTS_ENVIRONMENT and as a client of init.sh functionality, as well as
 your proposed automake testcase addition to ensure we don't break it.
 
 
I'll then push the attached patch to automake master soonish (by tomorrow
or so) if there is no objection by then.

Regards,
  Stefano
From 9f80020a24110e599b7dbdc5699dc8dbf5af0bd2 Mon Sep 17 00:00:00 2001
Message-Id: 9f80020a24110e599b7dbdc5699dc8dbf5af0bd2.1308037344.git.stefano.lattar...@gmail.com
From: Stefano Lattarini stefano.lattar...@gmail.com
Date: Tue, 14 Jun 2011 09:41:14 +0200
Subject: [PATCH] tests: check portable fd redirection in TESTS_ENVIRONMENT

* tests/tests-environment-fd-redirect.test: New test.
* tests/Makefile.am (TESTS): Update.

Motivated by coreutils bug#8846:
 http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8846
See also following CC:ed thread on bug-autoconf list:
 http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg2.html
---
 ChangeLog|   10 
 tests/Makefile.am|1 +
 tests/Makefile.in|1 +
 tests/tests-environment-fd-redirect.test |   75 ++
 4 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100755 tests/tests-environment-fd-redirect.test

diff --git a/ChangeLog b/ChangeLog
index aad41c7..e482cbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-06-14  Stefano Lattarini  stefano.lattar...@gmail.com
+
+	tests: check portable fd redirection in TESTS_ENVIRONMENT
+	* tests/tests-environment-fd-redirect.test: New test.
+	* tests/Makefile.am (TESTS): Update.
+	Motivated by coreutils bug#8846:
+	 http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8846
+	See also following CC:ed thread on bug-autoconf list:
+	 http://lists.gnu.org/archive/html/bug-autoconf/2011-06/msg2.html
+
 2011-06-08  Stefano Lattarini  stefano.lattar...@gmail.com
 
 	test defs: new function 'fatal_', for hard errors
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e68f6d7..c0f39ce 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -949,6 +949,7 @@ tar2.test \
 tar3.test \
 target-cflags.test \
 targetclash.test \
+tests-environment-fd-redirect.test \
 txinfo.test \
 txinfo2.test \
 txinfo3.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 7e5fd09..4c223fc 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1216,6 +1216,7 @@ tar2.test \
 tar3.test \
 target-cflags.test \
 targetclash.test \
+tests-environment-fd-redirect.test \
 txinfo.test \
 txinfo2.test \
 txinfo3.test \
diff --git a/tests/tests-environment-fd-redirect.test b/tests/tests-environment-fd-redirect.test
new file mode 100755
index 000..2a0afa9
--- /dev/null
+++ b/tests/tests-environment-fd-redirect.test
@@ -0,0 +1,75 @@
+#! /bin/sh
+# Copyright (C) 2011 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see http://www.gnu.org/licenses/.
+
+# Test for a behaviour of `TESTS_ENVIRONMENT' and `AM_TESTS_ENVIRONMENT'
+# w.r.t. file descriptor redirections which, although undocumented,
+# is nonetheless required by Gnulib's 'tests/init.sh' and by coreutils'
+# testsuite.
+# The checked behaviour is that we can portably do file descriptor
+# redirections by 

Re: bug#8846: coreutils-8.12 on HP-UX 11.31: 3 of 365 tests failed

2011-06-14 Thread Stefano Lattarini
On Tuesday 14 June 2011, Jim Meyering wrote:
 Here's what I expect to do for coreutils,
 along with an advice-update for gnulib's init.sh:

Thanks, I'll apply something similar to automake `tests/defs' soonish.
I have a doubt below, tough (see near the end).

 From e948173c1c461aac9f1c490061b257f55e42608d Mon Sep 17 00:00:00 2001
 From: Jim Meyering meyer...@redhat.com
 Date: Tue, 14 Jun 2011 09:59:14 +0200
 Subject: [PATCH] tests: accommodate HP-UX and Solaris shells
 
 Running make check normally prints a diagnostic to the outermost
 stderr (usually a tty) to explain why a test is skipped.  It did this
 by redirecting FD 9 to stderr (via exec 92) before invoking the
 shell script.  Shell scripts write skip-explanation to FD 9 via
 init.sh's skip_ function.  However, with Solaris 10's ksh and HP-UX,
 the effects of exec 92 are canceled upon fork-and-exec,

BTW, this is true also for the default ksh on Debian GNU/Linux (but
note that this is just a trivia fact, since on GNU/Linux basically
everybody uses either bash or dash as the non-interactive shell of
choice).

 so we would get a Bad file number diagnostic and no skip explanation
 on those systems.
 * tests/check.mk (TESTS_ENVIRONMENT): Redirect more portably, via
 $(SHELL) $$1 92, rather than the prior
 exec 92; $(SHELL) ...
 Actually, we use shell_or_perl_ 92, to make this effective
 also for the perl-based tests.
 * tests/init.sh (stderr_fileno_): Update the advice in comments.
 See http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22488
 for lots of discussion.  Stefano Lattarini suggested the solution
 of putting 92 after the command.  Reported by Bruno Haible.
 ---
  tests/check.mk |3 +--
  tests/init.sh  |4 ++--
  2 files changed, 3 insertions(+), 4 deletions(-)
 
 diff --git a/tests/check.mk b/tests/check.mk
 index db7f067..9db96af 100644
 --- a/tests/check.mk
 +++ b/tests/check.mk
 @@ -58,7 +58,6 @@ TESTS_ENVIRONMENT = \
test -d $$tmp__  test -w $$tmp__ || tmp__=.; \
. $(srcdir)/envvar-check;  \
TMPDIR=$$tmp__; export TMPDIR; \
 -  exec 92; \
shell_or_perl_() { \
  if grep '^\#!/usr/bin/perl' $$1  /dev/null; then  
 \
if $(PERL) -e 'use warnings'  /dev/null 21; then\
 @@ -100,6 +99,6 @@ TESTS_ENVIRONMENT =\
REPLACE_GETCWD=$(REPLACE_GETCWD)   \
; test -d /usr/xpg4/bin  PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'$$PATH; \
PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'$$PATH \
 -  ; shell_or_perl_
 +  ; shell_or_perl_ 92
 
  VERBOSE = yes
 diff --git a/tests/init.sh b/tests/init.sh
 index 60d1bc1..a769d8b 100644
 --- a/tests/init.sh
 +++ b/tests/init.sh
 @@ -68,8 +68,8 @@ Exit () { set +e; (exit $1); exit $1; }
 
  # Print warnings (e.g., about skipped and failed tests) to this file number.
  # Override by defining to say, 9, in init.cfg, and putting say,
 -# export ...ENVVAR_SETTINGS...; exec 92; $(SHELL) in the definition
 -# of TESTS_ENVIRONMENT in your tests/Makefile.am file.
 +#   export ...ENVVAR_SETTINGS...; $(SHELL) $$1 92

What is this `$$1' here for?

 +# in the definition of TESTS_ENVIRONMENT in your tests/Makefile.am file.
  # This is useful when using automake's parallel tests mode, to print
  # the reason for skip/failure to console, rather than to the .log files.
  : ${stderr_fileno_=2}
 --
 1.7.6.rc0.293.g40857
 

Regards,
  Stefano



Re: bug#8846: coreutils-8.12 on HP-UX 11.31: 3 of 365 tests failed

2011-06-14 Thread Jim Meyering
Stefano Lattarini wrote:

 On Tuesday 14 June 2011, Jim Meyering wrote:
 Here's what I expect to do for coreutils,
 along with an advice-update for gnulib's init.sh:

 Thanks, I'll apply something similar to automake `tests/defs' soonish.
 I have a doubt below, tough (see near the end).

 From e948173c1c461aac9f1c490061b257f55e42608d Mon Sep 17 00:00:00 2001
 From: Jim Meyering meyer...@redhat.com
 Date: Tue, 14 Jun 2011 09:59:14 +0200
 Subject: [PATCH] tests: accommodate HP-UX and Solaris shells

 Running make check normally prints a diagnostic to the outermost
 stderr (usually a tty) to explain why a test is skipped.  It did this
 by redirecting FD 9 to stderr (via exec 92) before invoking the
 shell script.  Shell scripts write skip-explanation to FD 9 via
 init.sh's skip_ function.  However, with Solaris 10's ksh and HP-UX,
 the effects of exec 92 are canceled upon fork-and-exec,

 BTW, this is true also for the default ksh on Debian GNU/Linux (but
 note that this is just a trivia fact, since on GNU/Linux basically
 everybody uses either bash or dash as the non-interactive shell of
 choice).

Thanks.

 so we would get a Bad file number diagnostic and no skip explanation
 on those systems.
 * tests/check.mk (TESTS_ENVIRONMENT): Redirect more portably, via
 $(SHELL) $$1 92, rather than the prior
 exec 92; $(SHELL) ...
 Actually, we use shell_or_perl_ 92, to make this effective
 also for the perl-based tests.
 * tests/init.sh (stderr_fileno_): Update the advice in comments.
 See http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22488
 for lots of discussion.  Stefano Lattarini suggested the solution
 of putting 92 after the command.  Reported by Bruno Haible.
 ---
  tests/check.mk |3 +--
  tests/init.sh  |4 ++--
  2 files changed, 3 insertions(+), 4 deletions(-)

 diff --git a/tests/check.mk b/tests/check.mk
 index db7f067..9db96af 100644
 --- a/tests/check.mk
 +++ b/tests/check.mk
 @@ -58,7 +58,6 @@ TESTS_ENVIRONMENT =\
test -d $$tmp__  test -w $$tmp__ || tmp__=.;\
. $(srcdir)/envvar-check; \
TMPDIR=$$tmp__; export TMPDIR;\
 -  exec 92;\
shell_or_perl_() {\
  if grep '^\#!/usr/bin/perl' $$1  /dev/null; then 
 \
if $(PERL) -e 'use warnings'  /dev/null 21; then   \
 @@ -100,6 +99,6 @@ TESTS_ENVIRONMENT =   \
REPLACE_GETCWD=$(REPLACE_GETCWD)  \
; test -d /usr/xpg4/bin  PATH='/usr/xpg4/bin$(PATH_SEPARATOR)'$$PATH; 
 \
PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'$$PATH \
 -  ; shell_or_perl_
 +  ; shell_or_perl_ 92

  VERBOSE = yes
 diff --git a/tests/init.sh b/tests/init.sh
 index 60d1bc1..a769d8b 100644
 --- a/tests/init.sh
 +++ b/tests/init.sh
 @@ -68,8 +68,8 @@ Exit () { set +e; (exit $1); exit $1; }

  # Print warnings (e.g., about skipped and failed tests) to this file number.
  # Override by defining to say, 9, in init.cfg, and putting say,
 -# export ...ENVVAR_SETTINGS...; exec 92; $(SHELL) in the definition
 -# of TESTS_ENVIRONMENT in your tests/Makefile.am file.
 +#   export ...ENVVAR_SETTINGS...; $(SHELL) $$1 92

 What is this `$$1' here for?

Good catch.  It doesn't belong.
I fixed the log, too.

From 67811abfda04dafdde114a50556f0e1d2e9b6270 Mon Sep 17 00:00:00 2001
From: Jim Meyering meyer...@redhat.com
Date: Tue, 14 Jun 2011 09:59:14 +0200
Subject: [PATCH] tests: accommodate HP-UX and Solaris shells

Running make check normally prints a diagnostic to the outermost
stderr (usually a tty) to explain why a test is skipped.  It did this
by redirecting FD 9 to stderr (via exec 92) before invoking the
shell script.  Shell scripts write skip-explanation to FD 9 via
init.sh's skip_ function.  However, with Solaris 10's ksh and HP-UX,
the effects of exec 92 are canceled upon fork-and-exec, so we
would get a Bad file number diagnostic and no skip explanation on
those systems.
* tests/check.mk (TESTS_ENVIRONMENT): Redirect more portably, via
$(SHELL) 92, rather than the prior exec 92; $(SHELL) ...
Actually, we use shell_or_perl_ 92, to make this effective
also for the perl-based tests.
* tests/init.sh (stderr_fileno_): Update the advice in comments.
See http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/22488
for lots of discussion.  Stefano Lattarini suggested the solution
of putting 92 after the command.  Reported by Bruno Haible.
---
 tests/check.mk |3 +--
 tests/init.sh  |4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/tests/check.mk b/tests/check.mk
index db7f067..9db96af 100644
--- a/tests/check.mk
+++ b/tests/check.mk
@@ -58,7 +58,6 @@ TESTS_ENVIRONMENT =   \
   test -d $$tmp__  test -w $$tmp__ || tmp__=.;   \
   . $(srcdir)/envvar-check;\
   TMPDIR=$$tmp__; export TMPDIR;   \
-  exec 92;   \
   shell_or_perl_() {

a few warnings in the 'ANSI C-conforming const' check when using clang

2011-06-14 Thread Austin English
I was recently testing Wine with the Clang static analyzer, which
found a few issues in wine's configure.ac:
http://source.winehq.org/git/wine.git/commitdiff/8521ebe79df39730ee62d518fde3751f45606061

there are a few more warnings, however, that come from autoconf itself:
austin@aw25 ~/wine-git $
~/src/llvm/tools/clang/tools/scan-build/scan-build clang foo.c
scan-build: 'clang' executable not found in
'/home/austin/src/llvm/tools/clang/tools/scan-build/bin'.
scan-build: Using 'clang' from path: /usr/local/bin/clang
foo.c:31:5: warning: Dereference of undefined pointer value
*t++ = 0;
^
foo.c:22:22: warning: Both operands to '-' always have the same value
  pcpcc = g + (g ? g-g : 0);
~^~
foo.c:22:14: warning: The right operand to '+' is always 0
  pcpcc = g + (g ? g-g : 0);
 ^ ~
foo.c:26:3: warning: Value stored to 'pcpcc' is never read
  pcpcc = (char const *const *) ppc;
  ^   ~
4 warnings generated.
scan-build: 4 bugs found.
scan-build: Run 'scan-view /tmp/scan-build-2011-06-14-3' to examine bug reports.

foo.c is attached, which is just that configure test in a standalone c file.

-- 
-Austin
#include stdio.h

int
main ()
{
/* FIXME: Include the comments suggested by Paul. */
#ifndef __cplusplus
  /* Ultrix mips cc rejects this.  */
  typedef int charset[2];
  const charset cs;
  /* SunOS 4.1.1 cc rejects this.  */
  char const *const *pcpcc;
  char **ppc;
  /* NEC SVR4.0.2 mips cc rejects this.  */
  struct point {int x, y;};
  static struct point const zero = {0,0};
  /* AIX XL C 1.02.0.0 rejects this.
 It does not let you subtract one const X* pointer from another in
 an arm of an if-expression whose if-part is not a constant
 expression */
  const char *g = string;
  pcpcc = g + (g ? g-g : 0);
  /* HPUX 7.0 cc rejects these. */
  ++pcpcc;
  ppc = (char**) pcpcc;
  pcpcc = (char const *const *) ppc;
  { /* SCO 3.2v4 cc rejects this.  */
char *t;
char const *s = 0 ? (char *) 0 : (char const *) 0;

*t++ = 0;
if (s) return 0;
  }
  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
int x[] = {25, 17};
const int *foo = x[0];
++foo;
  }
  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
typedef const int *iptr;
iptr p = 0;
++p;
  }
  { /* AIX XL C 1.02.0.0 rejects this saying
   k.c, line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
struct s { int j; const int *ap[3]; };
struct s *b; b-j = 5;
  }
  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
const int foo = 10;
if (!foo) return 0;
  }
  return !cs[0]  !zero.x;
#endif

  ;
  return 0;
}



Re: a few warnings in the 'ANSI C-conforming const' check when using clang

2011-06-14 Thread Austin English
On Tue, Jun 14, 2011 at 19:05, Eric Blake ebl...@redhat.com wrote:
 On 06/14/2011 07:47 PM, Austin English wrote:
 I was recently testing Wine with the Clang static analyzer, which
 found a few issues in wine's configure.ac:
 http://source.winehq.org/git/wine.git/commitdiff/8521ebe79df39730ee62d518fde3751f45606061

 there are a few more warnings, however, that come from autoconf itself:

 Thanks for the report.  However, we _can't_ play the warnings-free game
 for all possible compilers.  The best advice we can give is to just
 ignore these.  For the same reason, we tell people _not_ to configure
 with CFLAGS=-Werror.

Of course :). Those are the only warnings I get, and I didn't see a
similar report in the archives, wanted to pass the word along.

Cheers,
Austin