* [PATCH] toplev.c: Check for null argument to fprintf
@ 2020-04-28 7:03 Stefan Schulze Frielinghaus
2020-04-29 17:05 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Schulze Frielinghaus @ 2020-04-28 7:03 UTC (permalink / raw)
To: gcc-patches
Ensure that CF does not equal NULL in function output_stack_usage_1
before calling fprintf. This fixes the following warning/error:
gcc/toplev.c:976:13: error: argument 1 null where non-null expected [-Werror=nonnull]
976 | fprintf (cf, "\\n" HOST_WIDE_INT_PRINT_DEC " bytes (%s)",
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
977 | stack_usage,
| ~~~~~~~~~~~~
978 | stack_usage_kind_str[stack_usage_kind]);
An example call side where CF is NULL is in function output_stack_usage.
Bootstrapped and regtested successfully on S/390. Ok for master?
gcc/ChangeLog:
2020-04-28 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
* toplev.c (output_stack_usage_1): Ensure that first
argument to fprintf is not null.
---
gcc/toplev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 4c8be502c71..5c026feece2 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -972,7 +972,7 @@ output_stack_usage_1 (FILE *cf)
stack_usage += current_function_dynamic_stack_size;
}
- if (flag_callgraph_info & CALLGRAPH_INFO_STACK_USAGE)
+ if (cf && flag_callgraph_info & CALLGRAPH_INFO_STACK_USAGE)
fprintf (cf, "\\n" HOST_WIDE_INT_PRINT_DEC " bytes (%s)",
stack_usage,
stack_usage_kind_str[stack_usage_kind]);
--
2.25.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] toplev.c: Check for null argument to fprintf
2020-04-28 7:03 [PATCH] toplev.c: Check for null argument to fprintf Stefan Schulze Frielinghaus
@ 2020-04-29 17:05 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2020-04-29 17:05 UTC (permalink / raw)
To: Stefan Schulze Frielinghaus, gcc-patches
On Tue, 2020-04-28 at 09:03 +0200, Stefan Schulze Frielinghaus via Gcc-patches
wrote:
> Ensure that CF does not equal NULL in function output_stack_usage_1
> before calling fprintf. This fixes the following warning/error:
>
> gcc/toplev.c:976:13: error: argument 1 null where non-null expected [-
> Werror=nonnull]
> 976 | fprintf (cf, "\\n" HOST_WIDE_INT_PRINT_DEC " bytes (%s)",
> | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 977 | stack_usage,
> | ~~~~~~~~~~~~
> 978 | stack_usage_kind_str[stack_usage_kind]);
>
> An example call side where CF is NULL is in function output_stack_usage.
>
> Bootstrapped and regtested successfully on S/390. Ok for master?
>
> gcc/ChangeLog:
>
> 2020-04-28 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
>
> * toplev.c (output_stack_usage_1): Ensure that first
> argument to fprintf is not null.
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-29 17:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 7:03 [PATCH] toplev.c: Check for null argument to fprintf Stefan Schulze Frielinghaus
2020-04-29 17:05 ` Jeff Law
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).