gallium/aux/util/u_debug_stack.c: Silence -Wunused-result warning
authorGert Wollny <gw.fossdev@gmail.com>
Thu, 16 Nov 2017 15:09:36 +0000 (16:09 +0100)
committerBrian Paul <brianp@vmware.com>
Fri, 17 Nov 2017 16:27:56 +0000 (09:27 -0700)
asprintf is decorated with the attrbute "warn_unused_result", and if the
function call fails, the pointer "temp" will be undefined, but since it is
used later it should contain some usable value.
Test return value of asprintf and assign some save value to "temp" if
the call failed.

Signed-off-by: Gert Wollny <gw.fossdev@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com> (v1)
src/gallium/auxiliary/util/u_debug_stack.c

index 7013807b6b226e4d715cb8b2df35a5e5d2a57fc6..6ddacdb362f3ca65e6e63b8f145609cbfd38e7c8 100644 (file)
@@ -90,8 +90,8 @@ symbol_name_cached(unw_cursor_t *cursor, unw_proc_info_t *pip)
          procname[1] = 0;
       }
 
-      asprintf(&name, "%s%s", procname, ret == -UNW_ENOMEM ? "..." : "");
-
+      if (asprintf(&name, "%s%s", procname, ret == -UNW_ENOMEM ? "..." : "") == -1) 
+         name = "??";
       util_hash_table_set(symbols_hash, addr, (void*)name);
    }
    mtx_unlock(&symbols_mutex);