This patch refactors the DEFAULT_ENVBLK_SIZE definition into a header file for
reuse in other code, and renames it to match other definitions in that header.

Signed-off-by: Paul Dagnelie <p...@delphix.com>
---
 include/grub/lib/envblk.h | 1 +
 util/editenv.c            | 9 ++++-----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/grub/lib/envblk.h b/include/grub/lib/envblk.h
index 287c87105..b9067dc37 100644
--- a/include/grub/lib/envblk.h
+++ b/include/grub/lib/envblk.h
@@ -23,6 +23,7 @@
 #define GRUB_ENVBLK_DEFCFG     "grubenv"
 #define GRUB_ENVBLK_SRC_BLK    "block"
 #define GRUB_ENVBLK_SRC_FILE   "file"
+#define GRUB_ENVBLK_DEFAULT_SIZE      1024
 
 #ifndef ASM_FILE
 
diff --git a/util/editenv.c b/util/editenv.c
index 45aeba259..ef1aba25b 100644
--- a/util/editenv.c
+++ b/util/editenv.c
@@ -29,13 +29,12 @@
 #include <errno.h>
 #include <string.h>
 
-#define DEFAULT_ENVBLK_SIZE    1024
 #define GRUB_ENVBLK_MESSAGE    "# WARNING: Do not edit this file by tools 
other than "PACKAGE"-editenv!!!\n"
 
 void
 grub_util_create_envblk_buffer (char *buf, size_t size)
 {
-  if (size < DEFAULT_ENVBLK_SIZE)
+  if (size < GRUB_ENVBLK_DEFAULT_SIZE)
     grub_util_error (_("Envblock buffer too small"));
   char *pbuf;
   pbuf = buf;
@@ -53,8 +52,8 @@ grub_util_create_envblk_file (const char *name)
   FILE *fp;
   char *buf, *namenew;
 
-  buf = xmalloc (DEFAULT_ENVBLK_SIZE);
-  grub_util_create_envblk_buffer(buf, DEFAULT_ENVBLK_SIZE);
+  buf = xmalloc (GRUB_ENVBLK_DEFAULT_SIZE);
+  grub_util_create_envblk_buffer(buf, GRUB_ENVBLK_DEFAULT_SIZE);
 
   namenew = xasprintf ("%s.new", name);
   fp = grub_util_fopen (namenew, "wb");
@@ -62,7 +61,7 @@ grub_util_create_envblk_file (const char *name)
     grub_util_error (_("cannot open `%s': %s"), namenew,
                     strerror (errno));
 
-  if (fwrite (buf, 1, DEFAULT_ENVBLK_SIZE, fp) != DEFAULT_ENVBLK_SIZE)
+  if (fwrite (buf, 1, GRUB_ENVBLK_DEFAULT_SIZE, fp) != 
GRUB_ENVBLK_DEFAULT_SIZE)
     grub_util_error (_("cannot write to `%s': %s"), namenew,
                     strerror (errno));
 
-- 
2.19.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to