From: Lennart Poettering Date: Tue, 2 Apr 2019 12:50:36 +0000 (+0200) Subject: boot: use TAKE_PTR() where appropriate X-Git-Tag: v242~49^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1db999eb8774463ce1fe3fe24e7fffbdc1ccb16;p=platform%2Fupstream%2Fsystemd.git boot: use TAKE_PTR() where appropriate --- diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index 7b3e782..57c423b 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -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; diff --git a/src/boot/efi/util.c b/src/boot/efi/util.c index bc1d4ae..4134e22 100644 --- a/src/boot/efi/util.c +++ b/src/boot/efi/util.c @@ -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; }