bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compiling error


From: Jim Meyering
Subject: Re: compiling error
Date: Tue, 12 Aug 2008 23:07:12 +0200

Ralf Wildenhues <address@hidden> wrote:
> continuing the topic: misc/sort-merge failure
> <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14202/focus=14203>
> (also for me, neither of the suggestions there help)
> and <http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14235>
>
> * Jim Meyering wrote on Tue, Aug 05, 2008 at 11:10:44PM CEST:
>> Jeph Cowan <address@hidden> wrote:
>> >
>> > I tried both the patch and the subsequent commenting out of
>> > nmerge-no's ERR_SUBST line. Neither produced positive results. See
>> > attached file.
>>
>> It looks like mkstemp may be misbehaving on your system.
>> It seems to be setting the first byte of the template
>> string to \0.  Hence the bogus diagnostic.
>
> Yep, exactly:
>
> $ cat a.c
> #include <stdlib.h>
>
> int main()
> {
>   char s[] = "does/not/exist/XXXXXX";
>   int ret = mkstemp (s);
>   printf ("s is '%s', s+1 is '%s', ret is %d\n", s, s+1, ret);
>   return 0;
> }
> $ cc -o a a.c &&./a
> s is '', s+1 is 'oes/not/exist/2YApMa', ret is -1

Thanks!
This is actually due to a bug in sort.c.
It was using the template string after a failed mkstemp call.
But in that case (with EEXIST), that string is undefined.
Here's the fix:

>From 9fdfafbf34b3705cf364bac88b97970a4d32ee4e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 12 Aug 2008 23:05:27 +0200
Subject: [PATCH] sort: don't use undefined variable in mkstemp failure 
diagnostic

* src/sort.c (create_temp_file): Use temp_dir, not "file"
in diagnosing failed mkstemp, because "file" may be undefined.
* tests/misc/sort-merge: Adjust for new expected output.
---
 src/sort.c            |    2 +-
 tests/misc/sort-merge |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index b932a51..728c935 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -741,7 +741,7 @@ create_temp_file (int *pfd)
   errno = saved_errno;

   if (fd < 0)
-    die (_("cannot create temporary file"), file);
+    die (_("cannot create temporary file in"), temp_dir);

   *pfd = fd;
   return node;
diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge
index 985d7a4..53559bf 100755
--- a/tests/misc/sort-merge
+++ b/tests/misc/sort-merge
@@ -66,8 +66,8 @@ my @Tests =
      # this should fail since nmerge < # of input files, so
      # temp files are needed
      ['nmerge-no', "-m --batch-size=2 -T$badtmp", @inputs,
-        {ERR_SUBST=>"s|: $badtmp/sort.+||"},
-        {ERR=>"$prog: cannot create temporary file\n"}, {EXIT=>2}],
+        {ERR_SUBST=>"s|(: $badtmp):.*|\$1|"},
+        {ERR=>"$prog: cannot create temporary file in: $badtmp\n"}, {EXIT=>2}],

      # This used to fail because setting batch-size without also setting
      # buffer size would cause the buffer size to be set to the minimum.
--
1.6.0.rc2.38.g413e06




reply via email to

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