naccyde / rpms / systemd

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