chiark / gitweb /
Remove libidn checks/support
[elogind.git] / src / shared / efivars.c
index 8b2b6af4bcaf7c72792049d30c9f68674ed7e533..20067c601adb41d205c2a4eda7c8e7fbfbc7c333 100644 (file)
@@ -105,7 +105,7 @@ int efi_get_variable(
         uint32_t a;
         ssize_t n;
         struct stat st;
         uint32_t a;
         ssize_t n;
         struct stat st;
-        _cleanup_free_ void *buf;
+        _cleanup_free_ void *buf = NULL;
 
         assert(name);
         assert(value);
 
         assert(name);
         assert(value);
@@ -504,6 +504,7 @@ int efi_get_boot_options(uint16_t **options) {
         _cleanup_closedir_ DIR *dir = NULL;
         struct dirent *de;
         _cleanup_free_ uint16_t *list = NULL;
         _cleanup_closedir_ DIR *dir = NULL;
         struct dirent *de;
         _cleanup_free_ uint16_t *list = NULL;
+        size_t alloc = 0;
         int count = 0;
 
         assert(options);
         int count = 0;
 
         assert(options);
@@ -514,7 +515,6 @@ int efi_get_boot_options(uint16_t **options) {
 
         FOREACH_DIRENT(de, dir, return -errno) {
                 int id;
 
         FOREACH_DIRENT(de, dir, return -errno) {
                 int id;
-                uint16_t *t;
 
                 if (strncmp(de->d_name, "Boot", 4) != 0)
                         continue;
 
                 if (strncmp(de->d_name, "Boot", 4) != 0)
                         continue;
@@ -529,12 +529,10 @@ int efi_get_boot_options(uint16_t **options) {
                 if (id < 0)
                         continue;
 
                 if (id < 0)
                         continue;
 
-                t = realloc(list, (count + 1) * sizeof(uint16_t));
-                if (!t)
+                if (!GREEDY_REALLOC(list, alloc, count + 1))
                         return -ENOMEM;
 
                         return -ENOMEM;
 
-                list = t;
-                list[count ++] = id;
+                list[count++] = id;
         }
 
         qsort_safe(list, count, sizeof(uint16_t), cmp_uint16);
         }
 
         qsort_safe(list, count, sizeof(uint16_t), cmp_uint16);