public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c
@ 2016-03-11 15:32 Kyrill Tkachov
  2016-03-14 12:04 ` Bernd Schmidt
  2016-03-21 10:47 ` Ramana Radhakrishnan
  0 siblings, 2 replies; 6+ messages in thread
From: Kyrill Tkachov @ 2016-03-11 15:32 UTC (permalink / raw)
  To: GCC Patches; +Cc: Ramana Radhakrishnan, Richard Earnshaw

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

Hi all,

As reported in the PR we can end up calling fclose twice on a file, causing an error.
This patch fixes that by reorganising the logic a bit to ensure we return after closing
the file the first time.

Bootstrapped and tested on arm-none-linux-gnueabihf

Ok for trunk?

Thanks,
Kyrill

2016-03-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR driver/70132
     * config/arm/driver-arm.c (host_detect_local_cpu): Set file pointer
     to NULL after closing file.

[-- Attachment #2: arm-driver-close.patch --]
[-- Type: text/x-patch, Size: 551 bytes --]

diff --git a/gcc/config/arm/driver-arm.c b/gcc/config/arm/driver-arm.c
index 466743b9d47f4144b6aade23e3f311405736ffa2..95dc9d53b6c179946d62f45b2b0d4a21960405b8 100644
--- a/gcc/config/arm/driver-arm.c
+++ b/gcc/config/arm/driver-arm.c
@@ -128,12 +128,11 @@ host_detect_local_cpu (int argc, const char **argv)
 	}
     }
 
-  fclose (f);
-
-  if (val == NULL)
-    goto not_found;
-
-  return concat ("-m", argv[0], "=", val, NULL);
+  if (val)
+    {
+      fclose (f);
+      return concat ("-m", argv[0], "=", val, NULL);
+     }
 
 not_found:
   {

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c
  2016-03-11 15:32 [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c Kyrill Tkachov
@ 2016-03-14 12:04 ` Bernd Schmidt
  2016-03-23 10:31   ` Kyrill Tkachov
  2016-03-21 10:47 ` Ramana Radhakrishnan
  1 sibling, 1 reply; 6+ messages in thread
From: Bernd Schmidt @ 2016-03-14 12:04 UTC (permalink / raw)
  To: Kyrill Tkachov, GCC Patches; +Cc: Ramana Radhakrishnan, Richard Earnshaw

On 03/11/2016 04:32 PM, Kyrill Tkachov wrote:
>      PR driver/70132
>      * config/arm/driver-arm.c (host_detect_local_cpu): Set file pointer
>      to NULL after closing file.

Doesn't match the patch. Either variant is fine but please use the right 
combination :)


Bernd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c
  2016-03-11 15:32 [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c Kyrill Tkachov
  2016-03-14 12:04 ` Bernd Schmidt
@ 2016-03-21 10:47 ` Ramana Radhakrishnan
  2016-04-28  9:24   ` Kyrill Tkachov
  1 sibling, 1 reply; 6+ messages in thread
From: Ramana Radhakrishnan @ 2016-03-21 10:47 UTC (permalink / raw)
  To: Kyrill Tkachov; +Cc: GCC Patches, Ramana Radhakrishnan, Richard Earnshaw

On Fri, Mar 11, 2016 at 3:32 PM, Kyrill Tkachov
<kyrylo.tkachov@foss.arm.com> wrote:
> Hi all,
>
> As reported in the PR we can end up calling fclose twice on a file, causing
> an error.
> This patch fixes that by reorganising the logic a bit to ensure we return
> after closing
> the file the first time.
>
> Bootstrapped and tested on arm-none-linux-gnueabihf
>
> Ok for trunk?
>
> Thanks,
> Kyrill
>
> 2016-03-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
>     PR driver/70132
>     * config/arm/driver-arm.c (host_detect_local_cpu): Set file pointer
>     to NULL after closing file.


OK with a fixed changelog.

Ramana

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c
  2016-03-14 12:04 ` Bernd Schmidt
@ 2016-03-23 10:31   ` Kyrill Tkachov
  0 siblings, 0 replies; 6+ messages in thread
From: Kyrill Tkachov @ 2016-03-23 10:31 UTC (permalink / raw)
  To: Bernd Schmidt, GCC Patches; +Cc: Ramana Radhakrishnan, Richard Earnshaw


On 14/03/16 12:04, Bernd Schmidt wrote:
> On 03/11/2016 04:32 PM, Kyrill Tkachov wrote:
>>      PR driver/70132
>>      * config/arm/driver-arm.c (host_detect_local_cpu): Set file pointer
>>      to NULL after closing file.
>
> Doesn't match the patch. Either variant is fine but please use the right combination :)
>
>

Sorry, that ChangeLog was from a earlier revision of the patch.
The correct one is:

2016-03-23  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR driver/70132
     * config/arm/driver-arm.c (host_detect_local_cpu): Reorder exit logic
     to not call fclose twice on file.


Committed with r234419.

Thanks,
Kyrill

> Bernd
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c
  2016-03-21 10:47 ` Ramana Radhakrishnan
@ 2016-04-28  9:24   ` Kyrill Tkachov
  2016-04-28  9:54     ` Ramana Radhakrishnan
  0 siblings, 1 reply; 6+ messages in thread
From: Kyrill Tkachov @ 2016-04-28  9:24 UTC (permalink / raw)
  To: Ramana Radhakrishnan; +Cc: GCC Patches, Ramana Radhakrishnan, Richard Earnshaw


On 21/03/16 10:41, Ramana Radhakrishnan wrote:
> On Fri, Mar 11, 2016 at 3:32 PM, Kyrill Tkachov
> <kyrylo.tkachov@foss.arm.com> wrote:
>> Hi all,
>>
>> As reported in the PR we can end up calling fclose twice on a file, causing
>> an error.
>> This patch fixes that by reorganising the logic a bit to ensure we return
>> after closing
>> the file the first time.
>>
>> Bootstrapped and tested on arm-none-linux-gnueabihf
>>
>> Ok for trunk?
>>
>> Thanks,
>> Kyrill
>>
>> 2016-03-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>>
>>      PR driver/70132
>>      * config/arm/driver-arm.c (host_detect_local_cpu): Set file pointer
>>      to NULL after closing file.
>
> OK with a fixed changelog.

Ok to backport this to the GCC 5 and 4.9 branches?
The tests are fine there for this patch.

Thank,
Kyrill

> Ramana

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c
  2016-04-28  9:24   ` Kyrill Tkachov
@ 2016-04-28  9:54     ` Ramana Radhakrishnan
  0 siblings, 0 replies; 6+ messages in thread
From: Ramana Radhakrishnan @ 2016-04-28  9:54 UTC (permalink / raw)
  To: Kyrill Tkachov; +Cc: GCC Patches, Ramana Radhakrishnan, Richard Earnshaw

On Thu, Apr 28, 2016 at 10:24 AM, Kyrill Tkachov
<kyrylo.tkachov@foss.arm.com> wrote:
>
> On 21/03/16 10:41, Ramana Radhakrishnan wrote:
>>
>> On Fri, Mar 11, 2016 at 3:32 PM, Kyrill Tkachov
>> <kyrylo.tkachov@foss.arm.com> wrote:
>>>
>>> Hi all,
>>>
>>> As reported in the PR we can end up calling fclose twice on a file,
>>> causing
>>> an error.
>>> This patch fixes that by reorganising the logic a bit to ensure we return
>>> after closing
>>> the file the first time.
>>>
>>> Bootstrapped and tested on arm-none-linux-gnueabihf
>>>
>>> Ok for trunk?
>>>
>>> Thanks,
>>> Kyrill
>>>
>>> 2016-03-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>>>
>>>      PR driver/70132
>>>      * config/arm/driver-arm.c (host_detect_local_cpu): Set file pointer
>>>      to NULL after closing file.
>>
>>
>> OK with a fixed changelog.
>
>
> Ok to backport this to the GCC 5 and 4.9 branches?
> The tests are fine there for this patch.

OK.

Ramana

>
> Thank,
> Kyrill
>
>> Ramana
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-28  9:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-11 15:32 [PATCH][ARM] PR driver/70132: Avoid double fclose in driver-arm.c Kyrill Tkachov
2016-03-14 12:04 ` Bernd Schmidt
2016-03-23 10:31   ` Kyrill Tkachov
2016-03-21 10:47 ` Ramana Radhakrishnan
2016-04-28  9:24   ` Kyrill Tkachov
2016-04-28  9:54     ` Ramana Radhakrishnan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).