GNU bug report logs -
#9064
coreutils-8.12 compiler warning
Previous Next
Full log
View this message in rfc822 format
Pádraig Brady wrote:
>On 13/07/11 14:11, Eric Blake wrote:
>> On 07/13/2011 03:05 AM, Pádraig Brady wrote:
>>> On 13/07/11 08:55, Joachim Schmitz wrote:
>>>> I found this in mktemp.c, line344 (well, my compiler found it for me and
>>>> warned about 'possible use of "=" where "==" was intended'):
>>>>
>>>> if (!dry_run && (stdout_closed = true) && close_stream (stdout) != 0)
>>>>
>>>> Not sure whether this is bug or feature ;-)
>>>
>>> Well it's a feature.
>>> We could reorganize but it would add a few more lines.
>>
>> Does this avoid the warning?
>>
>> if (!dry_run && ((stdout_closed = true), close_stream (stdout) != 0))
>>
>> That is, using the comma operator rather than an always-true conditional
>> since we always want the assignment to occur at that part of the expression?
>
> +1 for this version
As Joachim wrote (off-ML) that his compiler didn't complain about
the other, similar place in src/stat.c, the following patch doesn't
touch that one (as my first patch did: http://debbugs.gnu.org/9064#19).
From 2fc0d6282d304a76241eb66f0f0627fb189e3ec9 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail <at> bernhard-voelker.de>
Date: Thu, 14 Jul 2011 09:19:55 +0200
Subject: [PATCH] maint: fix warning 'possible use of "=" where "==" was
intended'
* src/mktemp.c: maint: avoid warning by using the comma operator
rather than an always-true conditional (as suggested by Eric Blake).
Reported by Joachim Schmitz in http://debbugs.gnu.org/9064.
---
src/mktemp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/mktemp.c b/src/mktemp.c
index 2fe22b7..e592176 100644
--- a/src/mktemp.c
+++ b/src/mktemp.c
@@ -344,7 +344,7 @@ main (int argc, char **argv)
puts (dest_name);
/* If we created a file, but then failed to output the file
name, we should clean up the mess before failing. */
- if (!dry_run && (stdout_closed = true) && close_stream (stdout) != 0)
+ if (!dry_run && ((stdout_closed = true), close_stream (stdout) != 0))
{
int saved_errno = errno;
remove (dest_name);
--
1.7.5.1
Have a nice day,
Berny
This bug report was last modified 13 years and 313 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.