From: Stefan Schulze Frielinghaus Date: Sun, 26 Apr 2020 07:26:39 +0000 (+0200) Subject: toplev.c: Check for null argument to fprintf X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c9450bf5c5c71945ec4474cd0f8bf830e431806;p=gcc.git toplev.c: Check for null argument to fprintf 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. gcc/ChangeLog: 2020-04-30 Stefan Schulze Frielinghaus * toplev.c (output_stack_usage_1): Ensure that first argument to fprintf is not null. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fc15925aa56..8abb4c0eda4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2020-04-30 Stefan Schulze Frielinghaus + + * toplev.c (output_stack_usage_1): Ensure that first + argument to fprintf is not null. + 2020-04-29 Jakub Jelinek * configure.ac (-with-changes-root-url): New configure option, 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]);