public inbox for bzip2-devel@sourceware.org
 help / color / mirror / Atom feed
From: "mark at klomp dot org" <sourceware-bugzilla@sourceware.org>
To: bzip2-devel@sourceware.org
Subject: [Bug bzip2/28904] libbzip2: ‘cost[3]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
Date: Tue, 19 Apr 2022 22:04:52 +0000	[thread overview]
Message-ID: <bug-28904-11876-jVg8x7RUhY@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28904-11876@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28904

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-04-19
     Ever confirmed|0                           |1
                 CC|                            |mark at klomp dot org

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
Sorry for the late reply.

I think you are right that initializing these two small (6 ints) arrays at the
start of the function is fine if it helps the compiler.

I haven't been able to reproduce the compiler warning myself though.
My proposed patch would be:

diff --git a/compress.c b/compress.c
index 5dfa002..c825c78 100644
--- a/compress.c
+++ b/compress.c
@@ -253,8 +253,8 @@ void sendMTFValues ( EState* s )
    --*/


-   UInt16 cost[BZ_N_GROUPS];
-   Int32  fave[BZ_N_GROUPS];
+   UInt16 cost[BZ_N_GROUPS] = { 0 };
+   Int32  fave[BZ_N_GROUPS] = { 0 };

    UInt16* mtfv = s->mtfv;


{ 0 } initializes the whole array with zero, so we don't have to know the exact
number of elements.

Does the above work for you?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  reply	other threads:[~2022-04-19 22:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-18  3:18 [Bug bzip2/28904] New: " demerphq at gmail dot com
2022-04-19 22:04 ` mark at klomp dot org [this message]
2022-04-19 22:23 ` [Bug bzip2/28904] " mark at klomp dot org
2022-04-20  1:57 ` demerphq at gmail dot com
2022-05-26 20:53 ` mark at klomp dot org
2022-05-31 19:06 ` email at arsoftware dot net.br

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28904-11876-jVg8x7RUhY@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=bzip2-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).