tree-wide: avoid uninitialized warning on _cleanup_ variables

With some versions of the compiler, the _cleanup_ attr makes it think
the variable might be freed/closed when uninitialized, even though it
cannot happen. The added cost is small enough to be worth the benefit,
and optimized builds will help reduce it even further.
This commit is contained in:
Luca Boccassi
2021-04-14 12:25:06 +01:00
parent be084c0dd1
commit c2b2df604b
61 changed files with 106 additions and 106 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ static int acquire_path(void) {
strv_free_and_replace(arg_path, a);
if (DEBUG_LOGGING) {
_cleanup_free_ char *j;
_cleanup_free_ char *j = NULL;
j = strv_join(arg_path, ":");
log_debug("Using %s as boot loader drop-in search path.", j);
+1 -1
View File
@@ -312,7 +312,7 @@ static int status_variables(void) {
}
static int boot_entry_file_check(const char *root, const char *p) {
_cleanup_free_ char *path;
_cleanup_free_ char *path = NULL;
path = path_join(root, p);
if (!path)
+1 -1
View File
@@ -456,7 +456,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
device_path = DevicePathFromHandle(entry->device);
if (device_path) {
_cleanup_freepool_ CHAR16 *str;
_cleanup_freepool_ CHAR16 *str = NULL;
str = DevicePathToStr(device_path);
Print(L"device handle '%s'\n", str);
+3 -3
View File
@@ -92,7 +92,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
* is non-NULL explicitly.) */
if (efivar_get_raw(LOADER_GUID, L"LoaderImageIdentifier", NULL, NULL) != EFI_SUCCESS &&
loaded_image->FilePath) {
_cleanup_freepool_ CHAR16 *s;
_cleanup_freepool_ CHAR16 *s = NULL;
s = DevicePathToStr(loaded_image->FilePath);
efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0);
@@ -100,7 +100,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* if LoaderFirmwareInfo is not set, let's set it */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareInfo", NULL, NULL) != EFI_SUCCESS) {
_cleanup_freepool_ CHAR16 *s;
_cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0);
@@ -108,7 +108,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
/* ditto for LoaderFirmwareType */
if (efivar_get_raw(LOADER_GUID, L"LoaderFirmwareType", NULL, NULL) != EFI_SUCCESS) {
_cleanup_freepool_ CHAR16 *s;
_cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0);
+1 -1
View File
@@ -379,7 +379,7 @@ EFI_STATUS file_read(EFI_FILE_HANDLE dir, const CHAR16 *name, UINTN off, UINTN s
return err;
if (size == 0) {
_cleanup_freepool_ EFI_FILE_INFO *info;
_cleanup_freepool_ EFI_FILE_INFO *info = NULL;
info = LibFileInfo(handle);
if (!info)