boot: use TAKE_PTR() where appropriate
authorLennart Poettering <lennart@poettering.net>
Tue, 2 Apr 2019 12:50:36 +0000 (14:50 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 2 Apr 2019 12:54:42 +0000 (14:54 +0200)
src/boot/efi/boot.c
src/boot/efi/util.c

index 7b3e782..57c423b 100644 (file)
@@ -269,10 +269,8 @@ static BOOLEAN line_edit(
 
                 case KEYPRESS(0, 0, CHAR_LINEFEED):
                 case KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN):
-                        if (StrCmp(line, line_in) != 0) {
-                                *line_out = line;
-                                line = NULL;
-                        }
+                        if (StrCmp(line, line_in) != 0)
+                                *line_out = TAKE_PTR(line);
                         enter = TRUE;
                         exit = TRUE;
                         break;
@@ -1258,8 +1256,7 @@ static VOID config_entry_bump_counters(
         /* If the file we just renamed is the loader path, then let's update that. */
         if (StrCmp(entry->loader, old_path) == 0) {
                 FreePool(entry->loader);
-                entry->loader = new_path;
-                new_path = NULL;
+                entry->loader = TAKE_PTR(new_path);
         }
 }
 
@@ -1360,10 +1357,8 @@ static VOID config_entry_add_from_file(
                                 s = PoolPrint(L"%s %s", entry->options, new);
                                 FreePool(entry->options);
                                 entry->options = s;
-                        } else {
-                                entry->options = new;
-                                new = NULL;
-                        }
+                        } else
+                                entry->options = TAKE_PTR(new);
 
                         continue;
                 }
@@ -1382,10 +1377,8 @@ static VOID config_entry_add_from_file(
                         s = PoolPrint(L"%s %s", initrd, entry->options);
                         FreePool(entry->options);
                         entry->options = s;
-                } else {
-                        entry->options = initrd;
-                        initrd = NULL;
-                }
+                } else
+                        entry->options = TAKE_PTR(initrd);
         }
 
         entry->device = device;
index bc1d4ae..4134e22 100644 (file)
@@ -122,8 +122,7 @@ EFI_STATUS efivar_get(const CHAR16 *name, CHAR16 **value) {
 
         /* Return buffer directly if it happens to be NUL terminated already */
         if (size >= 2 && buf[size-2] == 0 && buf[size-1] == 0) {
-                *value = (CHAR16*) buf;
-                buf = NULL;
+                *value = (CHAR16*) TAKE_PTR(buf);
                 return EFI_SUCCESS;
         }