GNU bug report logs - #9064
coreutils-8.12 compiler warning

Previous Next

Package: coreutils;

Reported by: "Joachim Schmitz" <jojo <at> schmitz-digital.de>

Date: Wed, 13 Jul 2011 07:57:01 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9064 in the body.
You can then email your comments to 9064 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9064; Package coreutils. (Wed, 13 Jul 2011 07:57:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Joachim Schmitz" <jojo <at> schmitz-digital.de>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 13 Jul 2011 07:57:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Joachim Schmitz" <jojo <at> schmitz-digital.de>
To: <bug-coreutils <at> gnu.org>
Subject: RE: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 09:55:51 +0200
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 ;-)

Bye, Jojo






Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9064; Package coreutils. (Wed, 13 Jul 2011 09:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 9064 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Joachim Schmitz <jojo <at> schmitz-digital.de>
Cc: 9064 <at> debbugs.gnu.org
Subject: Re: bug#9064: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 10:05:15 +0100
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.
What compiler (option) is this?
Is the warning avoided by using double brackets like ((stdout_closed = true))

cheers,
Pádraig.




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9064; Package coreutils. (Wed, 13 Jul 2011 09:14:01 GMT) Full text and rfc822 format available.

Message #11 received at 9064 <at> debbugs.gnu.org (full text, mbox):

From: "Joachim Schmitz" <jojo <at> schmitz-digital.de>
To: 'Pádraig Brady' <P <at> draigBrady.com>
Cc: 9064 <at> debbugs.gnu.org
Subject: RE: bug#9064: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 11:13:02 +0200
Double backet does not fix this warning. It is the HP NonStop c89 and c99
compiler without having disabled warnings (all warnings are on by default)
If it isn't a bug, forget about it, or maybe add a comment next to that line
about this.

-----Original Message-----
From: Pádraig Brady [mailto:P <at> draigBrady.com] 
Sent: Wednesday, July 13, 2011 11:05 AM
To: Joachim Schmitz
Cc: 9064 <at> debbugs.gnu.org
Subject: Re: bug#9064: coreutils-8.12 compiler warning

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.
What compiler (option) is this?
Is the warning avoided by using double brackets like ((stdout_closed =
true))

cheers,
Pádraig.





Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Wed, 13 Jul 2011 09:35:02 GMT) Full text and rfc822 format available.

Notification sent to "Joachim Schmitz" <jojo <at> schmitz-digital.de>:
bug acknowledged by developer. (Wed, 13 Jul 2011 09:35:02 GMT) Full text and rfc822 format available.

Message #16 received at 9064-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Joachim Schmitz <jojo <at> schmitz-digital.de>
Cc: 9064-done <at> debbugs.gnu.org
Subject: Re: bug#9064: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 10:32:44 +0100
On 13/07/11 10:13, Joachim Schmitz wrote:
> Double backet does not fix this warning. It is the HP NonStop c89 and c99
> compiler without having disabled warnings (all warnings are on by default)
> If it isn't a bug, forget about it, or maybe add a comment next to that line
> about this.
> 
> -----Original Message-----
> From: Pádraig Brady [mailto:P <at> draigBrady.com] 
> Sent: Wednesday, July 13, 2011 11:05 AM
> To: Joachim Schmitz
> Cc: 9064 <at> debbugs.gnu.org
> Subject: Re: bug#9064: coreutils-8.12 compiler warning
> 
> 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.
> What compiler (option) is this?
> Is the warning avoided by using double brackets like ((stdout_closed =
> true))

I also notice SGI's compiler has similar issues
http://archive.apache.org/gnats/2528

closing this.

cheers,
Pádraig.




Message #17 received at 9064-done <at> debbugs.gnu.org (full text, mbox):

From: "Voelker, Bernhard" <bernhard.voelker <at> siemens-enterprise.com>
To: Pádraig Brady <P <at> draigBrady.com>, Joachim Schmitz
	<jojo <at> schmitz-digital.de>
Cc: "9064-done <at> debbugs.gnu.org" <9064-done <at> debbugs.gnu.org>
Subject: RE: bug#9064: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 12:12:49 +0200
Pádraig Brady wrote:

> On 13/07/11 10:13, Joachim Schmitz wrote:
>> Double backet does not fix this warning. It is the HP NonStop c89 and c99
>> compiler without having disabled warnings (all warnings are on by default)
>> If it isn't a bug, forget about it, or maybe add a comment next to that line
>> about this.
>> 
>> -----Original Message-----
>> From: Pádraig Brady [mailto:P <at> draigBrady.com] 
>> Sent: Wednesday, July 13, 2011 11:05 AM
>> To: Joachim Schmitz
>> Cc: 9064 <at> debbugs.gnu.org
>> Subject: Re: bug#9064: coreutils-8.12 compiler warning
>> 
>> 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.
>> What compiler (option) is this?
>> Is the warning avoided by using double brackets like ((stdout_closed =
>> true))
>
> I also notice SGI's compiler has similar issues
> http://archive.apache.org/gnats/2528
> 
> closing this.

I remember I've seen something like (0 != (stdout_closed = true))
to make the compiler happy.

This is like the often used
  if (0 == (fp = fopen("file", "r"))
    ... error

Have a nice day,
Berny






Message #18 received at 9064-done <at> debbugs.gnu.org (full text, mbox):

From: "Joachim Schmitz" <jojo <at> schmitz-digital.de>
To: "'Voelker, Bernhard'" <bernhard.voelker <at> siemens-enterprise.com>,
	'Pádraig Brady' <P <at> draigBrady.com>
Cc: 9064-done <at> debbugs.gnu.org
Subject: RE: bug#9064: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 12:56:18 +0200
From: Voelker, Bernhard 

>I remember I've seen something like (0 != (stdout_closed = true)) to make
the compiler happy.

Yes, that change would make my compiler happy too.





Message #19 received at 9064-done <at> debbugs.gnu.org (full text, mbox):

From: "Voelker, Bernhard" <bernhard.voelker <at> siemens-enterprise.com>
To: Joachim Schmitz <jojo <at> schmitz-digital.de>,
	'Pádraig Brady' <P <at> draigBrady.com>
Cc: "9064-done <at> debbugs.gnu.org" <9064-done <at> debbugs.gnu.org>
Subject: RE: bug#9064: [PATCH] coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 14:59:14 +0200
Joachim Schmitz wrote:

> From: Voelker, Bernhard 
>> I remember I've seen something like (0 != (stdout_closed = true)) to make
>> the compiler happy.
> 
> Yes, that change would make my compiler happy too.

A search using `find . -type f -name '*.c' | xargs grep ' if .* = '`
unveiled a second place in stat.c.
Here's a corresponding patch to avoid both warnings.


From cef2afe553f821f2eb716b90623581e790ce67a3 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <mail <at> bernhard-voelker.de>
Date: Wed, 13 Jul 2011 14:50:38 +0200
Subject: [PATCH] maint: fix warning 'possible use of "=" where "==" was
 intended'

* src/mktemp.c: avoid warning by enclosing in double brackets
  and comparison "!= 0".
* src/stat.c: Likewise.
---
 src/mktemp.c |    2 +-
 src/stat.c   |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mktemp.c b/src/mktemp.c
index c6d0e58..c2ab025 100644
--- a/src/mktemp.c
+++ b/src/mktemp.c
@@ -341,7 +341,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) != 0) && close_stream (stdout) != 0)
         {
           int saved_errno = errno;
           remove (dest_name);
diff --git a/src/stat.c b/src/stat.c
index 0ad465e..bd60457 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -834,7 +834,7 @@ out_mount_point (char const *filename, char *pformat, size_t prefix_len,
      Note we don't detect if any of the directory components
      are bind mounted to the same device, but that's OK
      since we've not directly queried them.  */
-  if ((mp = find_mount_point (filename, statp)))
+  if ((mp = find_mount_point (filename, statp)) != 0)
     {
       /* This dir might be bind mounted to another device,
          so we resolve the bound source in that case also.  */
-- 
1.7.5.1

Have a nice day,
Berny




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9064; Package coreutils. (Wed, 13 Jul 2011 13:12:02 GMT) Full text and rfc822 format available.

Message #22 received at 9064 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: Joachim Schmitz <jojo <at> schmitz-digital.de>, 9064 <at> debbugs.gnu.org
Subject: Re: bug#9064: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 07:11:22 -0600
[Message part 1 (text/plain, inline)]
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?

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Message #23 received at 9064-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: "Voelker, Bernhard" <bernhard.voelker <at> siemens-enterprise.com>
Cc: Joachim Schmitz <jojo <at> schmitz-digital.de>,
	"9064-done <at> debbugs.gnu.org" <9064-done <at> debbugs.gnu.org>
Subject: Re: bug#9064: [PATCH] coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 14:09:33 +0100
On 13/07/11 13:59, Voelker, Bernhard wrote:
> Joachim Schmitz wrote:
> 
>> From: Voelker, Bernhard 
>>> I remember I've seen something like (0 != (stdout_closed = true)) to make
>>> the compiler happy.
>>
>> Yes, that change would make my compiler happy too.
> 
> A search using `find . -type f -name '*.c' | xargs grep ' if .* = '`
> unveiled a second place in stat.c.
> Here's a corresponding patch to avoid both warnings.
> 
> 
>>From cef2afe553f821f2eb716b90623581e790ce67a3 Mon Sep 17 00:00:00 2001
> From: Bernhard Voelker <mail <at> bernhard-voelker.de>
> Date: Wed, 13 Jul 2011 14:50:38 +0200
> Subject: [PATCH] maint: fix warning 'possible use of "=" where "==" was
>  intended'
> 
> * src/mktemp.c: avoid warning by enclosing in double brackets
>   and comparison "!= 0".
> * src/stat.c: Likewise.
> ---
>  src/mktemp.c |    2 +-
>  src/stat.c   |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mktemp.c b/src/mktemp.c
> index c6d0e58..c2ab025 100644
> --- a/src/mktemp.c
> +++ b/src/mktemp.c
> @@ -341,7 +341,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) != 0) && close_stream (stdout) != 0)
>          {
>            int saved_errno = errno;
>            remove (dest_name);
> diff --git a/src/stat.c b/src/stat.c
> index 0ad465e..bd60457 100644
> --- a/src/stat.c
> +++ b/src/stat.c
> @@ -834,7 +834,7 @@ out_mount_point (char const *filename, char *pformat, size_t prefix_len,
>       Note we don't detect if any of the directory components
>       are bind mounted to the same device, but that's OK
>       since we've not directly queried them.  */
> -  if ((mp = find_mount_point (filename, statp)))
> +  if ((mp = find_mount_point (filename, statp)) != 0)
>      {
>        /* This dir might be bind mounted to another device,
>           so we resolve the bound source in that case also.  */


That would be slightly mangling the code to avoid a _warning_
on old buggy compilers.

I'm 60:40 against adding that.

cheers,
Pádraig.




Message #24 received at 9064-done <at> debbugs.gnu.org (full text, mbox):

From: "Voelker, Bernhard" <bernhard.voelker <at> siemens-enterprise.com>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: Joachim Schmitz <jojo <at> schmitz-digital.de>,
	"9064-done <at> debbugs.gnu.org" <9064-done <at> debbugs.gnu.org>
Subject: RE: bug#9064: [PATCH] coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 15:22:13 +0200
Pádraig Brady wrote:
> On 13/07/11 13:59, Voelker, Bernhard wrote:
>> Joachim Schmitz wrote:
>> 
>>> From: Voelker, Bernhard 
>>>> I remember I've seen something like (0 != (stdout_closed = true)) to make
>>>> the compiler happy.
>>>
>>> Yes, that change would make my compiler happy too.
>> 
>> A search using `find . -type f -name '*.c' | xargs grep ' if .* = '`
>> unveiled a second place in stat.c.
>> Here's a corresponding patch to avoid both warnings.
>> 
>> 
>>>From cef2afe553f821f2eb716b90623581e790ce67a3 Mon Sep 17 00:00:00 2001
>> From: Bernhard Voelker <mail <at> bernhard-voelker.de>
>> Date: Wed, 13 Jul 2011 14:50:38 +0200
>> Subject: [PATCH] maint: fix warning 'possible use of "=" where "==" was
>>  intended'
>> 
>> * src/mktemp.c: avoid warning by enclosing in double brackets
>>   and comparison "!= 0".
>> * src/stat.c: Likewise.
>> ---
>>  src/mktemp.c |    2 +-
>>  src/stat.c   |    2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/src/mktemp.c b/src/mktemp.c
>> index c6d0e58..c2ab025 100644
>> --- a/src/mktemp.c
>> +++ b/src/mktemp.c
>> @@ -341,7 +341,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) != 0) && close_stream (stdout) != 0)
>>          {
>>            int saved_errno = errno;
>>            remove (dest_name);
>> diff --git a/src/stat.c b/src/stat.c
>> index 0ad465e..bd60457 100644
>> --- a/src/stat.c
>> +++ b/src/stat.c
>> @@ -834,7 +834,7 @@ out_mount_point (char const *filename, char *pformat, size_t prefix_len,
>>       Note we don't detect if any of the directory components
>>       are bind mounted to the same device, but that's OK
>>       since we've not directly queried them.  */
>> -  if ((mp = find_mount_point (filename, statp)))
>> +  if ((mp = find_mount_point (filename, statp)) != 0)
>>      {
>>        /* This dir might be bind mounted to another device,
>>           so we resolve the bound source in that case also.  */
>
>
> That would be slightly mangling the code to avoid a _warning_
> on old buggy compilers.

well, my intension was not to satisfy the compiler primarily,
but IMO it enhances readability: it proves that the developer
did intensionally use '=' instead of '==' ... at least in the
first case. In the second, there were already double brackets,
but I thought it'd make also that one clearer.

Also think about Joachim's words:
>>>>> Not sure whether this is bug or feature ;-)

Have a nice day,
Berny



Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9064; Package coreutils. (Wed, 13 Jul 2011 13:49:02 GMT) Full text and rfc822 format available.

Message #27 received at 9064 <at> debbugs.gnu.org (full text, mbox):

From: "Joachim Schmitz" <jojo <at> schmitz-digital.de>
To: "'Eric Blake'" <eblake <at> redhat.com>,
	'Pádraig Brady' <P <at> draigBrady.com>
Cc: 9064 <at> debbugs.gnu.org
Subject: RE: bug#9064: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 15:48:00 +0200
That does indeed silence my compiler and is showing the intention pretty
clear

-----Original Message-----
From: Eric Blake [mailto:eblake <at> redhat.com] 
Sent: Wednesday, July 13, 2011 3:11 PM
To: Pádraig Brady
Cc: Joachim Schmitz; 9064 <at> debbugs.gnu.org
Subject: Re: bug#9064: coreutils-8.12 compiler warning

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?

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org






Message #28 received at 9064-done <at> debbugs.gnu.org (full text, mbox):

From: "Joachim Schmitz" <jojo <at> schmitz-digital.de>
To: 'Pádraig Brady' <P <at> draigBrady.com>,
	"'Voelker, Bernhard'" <bernhard.voelker <at> siemens-enterprise.com>
Cc: 9064-done <at> debbugs.gnu.org
Subject: RE: bug#9064: [PATCH] coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 15:48:06 +0200
That c99 compiler is pretty new, about 1/2 year.

-----Original Message-----
From: Pádraig Brady [mailto:P <at> draigBrady.com] 
Sent: Wednesday, July 13, 2011 3:10 PM
To: Voelker, Bernhard
Cc: Joachim Schmitz; 9064-done <at> debbugs.gnu.org
Subject: Re: bug#9064: [PATCH] coreutils-8.12 compiler warning

On 13/07/11 13:59, Voelker, Bernhard wrote:
> Joachim Schmitz wrote:
> 
>> From: Voelker, Bernhard
>>> I remember I've seen something like (0 != (stdout_closed = true)) to 
>>> make the compiler happy.
>>
>> Yes, that change would make my compiler happy too.
> 
> A search using `find . -type f -name '*.c' | xargs grep ' if .* = '` 
> unveiled a second place in stat.c.
> Here's a corresponding patch to avoid both warnings.
> 
> 
>>From cef2afe553f821f2eb716b90623581e790ce67a3 Mon Sep 17 00:00:00 2001
> From: Bernhard Voelker <mail <at> bernhard-voelker.de>
> Date: Wed, 13 Jul 2011 14:50:38 +0200
> Subject: [PATCH] maint: fix warning 'possible use of "=" where "==" 
> was  intended'
> 
> * src/mktemp.c: avoid warning by enclosing in double brackets
>   and comparison "!= 0".
> * src/stat.c: Likewise.
> ---
>  src/mktemp.c |    2 +-
>  src/stat.c   |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mktemp.c b/src/mktemp.c index c6d0e58..c2ab025 100644
> --- a/src/mktemp.c
> +++ b/src/mktemp.c
> @@ -341,7 +341,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) != 0) && close_stream 
> + (stdout) != 0)
>          {
>            int saved_errno = errno;
>            remove (dest_name);
> diff --git a/src/stat.c b/src/stat.c
> index 0ad465e..bd60457 100644
> --- a/src/stat.c
> +++ b/src/stat.c
> @@ -834,7 +834,7 @@ out_mount_point (char const *filename, char *pformat,
size_t prefix_len,
>       Note we don't detect if any of the directory components
>       are bind mounted to the same device, but that's OK
>       since we've not directly queried them.  */
> -  if ((mp = find_mount_point (filename, statp)))
> +  if ((mp = find_mount_point (filename, statp)) != 0)
>      {
>        /* This dir might be bind mounted to another device,
>           so we resolve the bound source in that case also.  */


That would be slightly mangling the code to avoid a _warning_ on old buggy
compilers.

I'm 60:40 against adding that.

cheers,
Pádraig.





Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9064; Package coreutils. (Wed, 13 Jul 2011 14:21:01 GMT) Full text and rfc822 format available.

Message #31 received at 9064 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Eric Blake <eblake <at> redhat.com>
Cc: Joachim Schmitz <jojo <at> schmitz-digital.de>, 9064 <at> debbugs.gnu.org
Subject: Re: bug#9064: coreutils-8.12 compiler warning
Date: Wed, 13 Jul 2011 15:18:40 +0100
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






Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9064; Package coreutils. (Thu, 14 Jul 2011 07:39:02 GMT) Full text and rfc822 format available.

Message #34 received at 9064 <at> debbugs.gnu.org (full text, mbox):

From: "Voelker, Bernhard" <bernhard.voelker <at> siemens-enterprise.com>
To: Pádraig Brady <P <at> draigBrady.com>, Eric Blake
	<eblake <at> redhat.com>
Cc: Joachim Schmitz <jojo <at> schmitz-digital.de>,
	"9064 <at> debbugs.gnu.org" <9064 <at> debbugs.gnu.org>
Subject: RE: bug#9064: [PATCH] coreutils-8.12 compiler warning
Date: Thu, 14 Jul 2011 09:38:21 +0200
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



Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9064; Package coreutils. (Thu, 14 Jul 2011 11:02:02 GMT) Full text and rfc822 format available.

Message #37 received at 9064 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: "Voelker, Bernhard" <bernhard.voelker <at> siemens-enterprise.com>
Cc: Joachim Schmitz <jojo <at> schmitz-digital.de>, Eric Blake <eblake <at> redhat.com>,
	"9064 <at> debbugs.gnu.org" <9064 <at> debbugs.gnu.org>
Subject: Re: bug#9064: [PATCH] coreutils-8.12 compiler warning
Date: Thu, 14 Jul 2011 11:59:39 +0100
On 14/07/11 08:38, Voelker, Bernhard wrote:
> * 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.

pushed.

cheers,
Pádraig.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 11 Aug 2011 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 266 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.