Skip to content

Commit 8d97fb3

Browse files
committed
gcc-plugins/stackleak: Avoid assignment for unused macro argument
With GCC version >= 8, the cgraph_create_edge() macro argument using "frequency" goes unused. Instead of assigning a temporary variable for the argument, pass the compute_call_stmt_bb_frequency() call directly as the macro argument so that it will just not be called when it is not wanted by the macros. Silences the warning: scripts/gcc-plugins/stackleak_plugin.c:54:6: warning: variable ‘frequency’ set but not used [-Wunused-but-set-variable] Now builds cleanly with gcc-7 and gcc-9. Both boot and pass STACKLEAK_ERASING LKDTM test. Signed-off-by: Kees Cook <[email protected]>
1 parent 8f3d9f3 commit 8d97fb3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

scripts/gcc-plugins/stackleak_plugin.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ static void stackleak_add_track_stack(gimple_stmt_iterator *gsi, bool after)
5151
gimple stmt;
5252
gcall *stackleak_track_stack;
5353
cgraph_node_ptr node;
54-
int frequency;
5554
basic_block bb;
5655

5756
/* Insert call to void stackleak_track_stack(void) */
@@ -68,9 +67,9 @@ static void stackleak_add_track_stack(gimple_stmt_iterator *gsi, bool after)
6867
bb = gimple_bb(stackleak_track_stack);
6968
node = cgraph_get_create_node(track_function_decl);
7069
gcc_assert(node);
71-
frequency = compute_call_stmt_bb_frequency(current_function_decl, bb);
7270
cgraph_create_edge(cgraph_get_node(current_function_decl), node,
73-
stackleak_track_stack, bb->count, frequency);
71+
stackleak_track_stack, bb->count,
72+
compute_call_stmt_bb_frequency(current_function_decl, bb));
7473
}
7574

7675
static bool is_alloca(gimple stmt)

0 commit comments

Comments
 (0)