From 0694c1a5ade124d776e3d15b64206417f91ddf9b Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 17 Feb 2022 21:46:39 +0000 Subject: [PATCH] gbacktrace: Fix a set-but-not-used variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s only used if building for lldb. Spotted in the log from an oss-fuzz build: https://oss-fuzz-build-logs.storage.googleapis.com/log-051f05da-adf5-42c1-8f14-5e36ba750573.txt: ``` Step #12 - "compile-honggfuzz-address-x86_64": [36/1232] Compiling C object glib/libglib-2.0.a.p/gbacktrace.c.o Step #12 - "compile-honggfuzz-address-x86_64": ../../src/glib/glib/gbacktrace.c:324:24: warning: variable 'line_idx' set but not used [-Wunused-but-set-variable] Step #12 - "compile-honggfuzz-address-x86_64": int sel, idx, state, line_idx; Step #12 - "compile-honggfuzz-address-x86_64": ^ Step #12 - "compile-honggfuzz-address-x86_64": 1 warning generated. ``` Signed-off-by: Philip Withnall --- glib/gbacktrace.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/glib/gbacktrace.c b/glib/gbacktrace.c index eb9ec8d66..77cef100a 100644 --- a/glib/gbacktrace.c +++ b/glib/gbacktrace.c @@ -321,7 +321,10 @@ stack_trace (const char * const *args) fd_set fdset; fd_set readset; struct timeval tv; - int sel, idx, state, line_idx; + int sel, idx, state; +#ifdef USE_LLDB + int line_idx; +#endif char buffer[BUFSIZE]; char c; @@ -382,7 +385,9 @@ stack_trace (const char * const *args) #endif idx = 0; +#ifdef USE_LLDB line_idx = 0; +#endif state = 0; while (1) @@ -399,7 +404,10 @@ stack_trace (const char * const *args) { if (read (out_fd[0], &c, 1)) { +#ifdef USE_LLDB line_idx += 1; +#endif + switch (state) { case 0: @@ -423,7 +431,9 @@ stack_trace (const char * const *args) _g_fprintf (stdout, "%s", buffer); state = 0; idx = 0; +#ifdef USE_LLDB line_idx = 0; +#endif } break; default: