efi_loader: correct includes in efi_variable.c
[oweals/u-boot.git] / lib / efi_loader / efi_variable.c
index 22ad271bd8524173522a3263862a30d9a0aafb46..46f35bc60ba0d4cfdbeed1cf3c02758864ee4bce 100644 (file)
@@ -5,14 +5,12 @@
  *  Copyright (c) 2017 Rob Clark
  */
 
-#include <env.h>
-#include <malloc.h>
-#include <charset.h>
+#include <common.h>
 #include <efi_loader.h>
-#include <hexdump.h>
 #include <env_internal.h>
+#include <hexdump.h>
+#include <malloc.h>
 #include <search.h>
-#include <uuid.h>
 
 #define READ_ONLY BIT(31)
 
@@ -443,8 +441,6 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
        if (ret)
                goto out;
 
-#define ACCESS_ATTR (EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS)
-
        old_val = env_get(native_name);
        if (old_val) {
                old_val = parse_attr(old_val, &attr);
@@ -455,7 +451,9 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
                        goto out;
                }
 
-               if ((data_size == 0) || !(attributes & ACCESS_ATTR)) {
+               if ((data_size == 0 &&
+                    !(attributes & EFI_VARIABLE_APPEND_WRITE)) ||
+                   !attributes) {
                        /* delete the variable: */
                        env_set(native_name, NULL);
                        ret = EFI_SUCCESS;
@@ -478,9 +476,12 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
                        old_size = 0;
                }
        } else {
-               if ((data_size == 0) || !(attributes & ACCESS_ATTR) ||
+               if (data_size == 0 || !attributes ||
                    (attributes & EFI_VARIABLE_APPEND_WRITE)) {
-                       /* delete, but nothing to do */
+                       /*
+                        * Trying to delete or to update a non-existent
+                        * variable.
+                        */
                        ret = EFI_NOT_FOUND;
                        goto out;
                }