From f2b3ecb84fc54c571cd8383f7aaefc625797a571 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Tue, 26 Jan 2021 13:48:22 -0500 Subject: [PATCH] softfloat: Silence a warning at -Og MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ../src/util/softfloat.c: In function ‘_mesa_shift_right_jam_m’: ../src/util/softfloat.c:432:16: warning: ‘tmp’ may be used uninitialized in this function [-Wmaybe-uninitialized] 432 | *tmp++ = 0; You could actually hit this if you called _mesa_shift_right_jam_m with size_words = 0 and dist < 32. Not that you'd _do_ that, but. In this case do nothing instead of writing through an uninitialized pointer. Reviewed-by: Eric Anholt Part-of: --- src/util/softfloat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/util/softfloat.c b/src/util/softfloat.c index 50cf098..cc386aa 100644 --- a/src/util/softfloat.c +++ b/src/util/softfloat.c @@ -393,6 +393,7 @@ _mesa_shift_right_jam_m(uint8_t size_words, const uint32_t *a, uint32_t dist, ui word_jam = 0; word_dist = dist >> 5; + tmp = NULL; if (word_dist) { if (size_words < word_dist) word_dist = size_words; @@ -428,10 +429,12 @@ _mesa_shift_right_jam_m(uint8_t size_words, const uint32_t *a, uint32_t dist, ui } tmp = m_out + index_multiword_hi(size_words, word_dist); } - do { - *tmp++ = 0; - --word_dist; - } while (word_dist); + if (tmp) { + do { + *tmp++ = 0; + --word_dist; + } while (word_dist); + } if (word_jam) m_out[index_word_lo(size_words)] |= 1; } -- 2.7.4