Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Apr 2026 23:03:12 +0000
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 92e5f6e1995a - main - x86/ucode: fix gcc uninitialised warning
Message-ID:  <69ee99b0.4659f.7edb9100@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by adrian:

URL: https://cgit.FreeBSD.org/src/commit/?id=92e5f6e1995acb10628ab210cc9f19dbf74f2948

commit 92e5f6e1995acb10628ab210cc9f19dbf74f2948
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2026-04-26 23:03:02 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2026-04-26 23:03:02 +0000

    x86/ucode: fix gcc uninitialised warning
    
    This fixes the case where selected_size is never set to anything
    in the loop.  Whilst here, also set selected_fw to NULL so the case
    of "no firmware" correctly sets everything to NULL/0.
    
    ```
      --- ucode_subr.o ---
      /workspace/src/sys/x86/x86/ucode_subr.c: In function 'ucode_amd_find':
      /workspace/src/sys/x86/x86/ucode_subr.c:237:25: warning: 'selected_size' may be used uninitialized [-Wmaybe-uninitialized]
        237 |         *selected_sizep = selected_size;
            |         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
    /  workspace/src/sys/x86/x86/ucode_subr.c:105:16: note: 'selected_size' was declared here
        105 |         size_t selected_size;
            |                ^~~~~~~~~~~~~
    ```
    
    Reviewed by:    emaste
    Differential Revision:  https://reviews.freebsd.org/D55439
---
 sys/x86/x86/ucode_subr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/x86/x86/ucode_subr.c b/sys/x86/x86/ucode_subr.c
index 53d7cfc06769..9536ed7b8f7b 100644
--- a/sys/x86/x86/ucode_subr.c
+++ b/sys/x86/x86/ucode_subr.c
@@ -98,11 +98,11 @@ ucode_amd_find(const char *path, uint32_t signature, uint32_t *revision,
     const uint8_t *fw_data, size_t fw_size, size_t *selected_sizep)
 {
 	const amd_10h_fw_header_t *fw_header;
-	const amd_10h_fw_header_t *selected_fw;
+	const amd_10h_fw_header_t *selected_fw = NULL;
 	const equiv_cpu_entry_t *equiv_cpu_table;
 	const section_header_t *section_header;
 	const container_header_t *container_header;
-	size_t selected_size;
+	size_t selected_size = 0;
 	uint16_t equiv_id;
 	int i;
 


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69ee99b0.4659f.7edb9100>