ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
ac3a84
From fdb8d8dee1821dc91c44b8f8195f959b9eae12ee Mon Sep 17 00:00:00 2001
ac3a84
From: Yu Watanabe <watanabe.yu+github@gmail.com>
ac3a84
Date: Tue, 6 Dec 2022 12:57:43 +0900
ac3a84
Subject: [PATCH] boot: fix false maybe-uninitialized warning
ac3a84
ac3a84
Fixes #25641.
ac3a84
ac3a84
(cherry picked from commit febe556191c739fb79a22cf742dd447c75e90446)
ac3a84
ac3a84
Related: #2141979
ac3a84
---
ac3a84
 src/boot/efi/boot.c        | 4 ++--
ac3a84
 src/boot/efi/cpio.c        | 2 +-
ac3a84
 src/boot/efi/secure-boot.c | 2 +-
ac3a84
 3 files changed, 4 insertions(+), 4 deletions(-)
ac3a84
ac3a84
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
ac3a84
index b490a1d972..db6ca97df4 100644
ac3a84
--- a/src/boot/efi/boot.c
ac3a84
+++ b/src/boot/efi/boot.c
ac3a84
@@ -1572,7 +1572,7 @@ static EFI_STATUS efivar_get_timeout(const char16_t *var, uint32_t *ret_value) {
ac3a84
 
ac3a84
 static void config_load_defaults(Config *config, EFI_FILE *root_dir) {
ac3a84
         _cleanup_free_ char *content = NULL;
ac3a84
-        UINTN value;
ac3a84
+        UINTN value = 0;  /* avoid false maybe-uninitialized warning */
ac3a84
         EFI_STATUS err;
ac3a84
 
ac3a84
         assert(root_dir);
ac3a84
@@ -2258,7 +2258,7 @@ static void config_load_xbootldr(
ac3a84
                 EFI_HANDLE *device) {
ac3a84
 
ac3a84
         _cleanup_(file_closep) EFI_FILE *root_dir = NULL;
ac3a84
-        EFI_HANDLE new_device;
ac3a84
+        EFI_HANDLE new_device = NULL;  /* avoid false maybe-uninitialized warning */
ac3a84
         EFI_STATUS err;
ac3a84
 
ac3a84
         assert(config);
ac3a84
diff --git a/src/boot/efi/cpio.c b/src/boot/efi/cpio.c
ac3a84
index 648f9f000f..1dbfe5f380 100644
ac3a84
--- a/src/boot/efi/cpio.c
ac3a84
+++ b/src/boot/efi/cpio.c
ac3a84
@@ -485,7 +485,7 @@ EFI_STATUS pack_cpio(
ac3a84
 
ac3a84
         for (UINTN i = 0; i < n_items; i++) {
ac3a84
                 _cleanup_free_ char *content = NULL;
ac3a84
-                UINTN contentsize;
ac3a84
+                UINTN contentsize = 0;  /* avoid false maybe-uninitialized warning */
ac3a84
 
ac3a84
                 err = file_read(extra_dir, items[i], 0, 0, &content, &contentsize);
ac3a84
                 if (err != EFI_SUCCESS) {
ac3a84
diff --git a/src/boot/efi/secure-boot.c b/src/boot/efi/secure-boot.c
ac3a84
index 65457bf423..6212868134 100644
ac3a84
--- a/src/boot/efi/secure-boot.c
ac3a84
+++ b/src/boot/efi/secure-boot.c
ac3a84
@@ -6,7 +6,7 @@
ac3a84
 #include "util.h"
ac3a84
 
ac3a84
 bool secure_boot_enabled(void) {
ac3a84
-        bool secure;
ac3a84
+        bool secure = false;  /* avoid false maybe-uninitialized warning */
ac3a84
         EFI_STATUS err;
ac3a84
 
ac3a84
         err = efivar_get_boolean_u8(EFI_GLOBAL_GUID, L"SecureBoot", &secure);