Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jC5Iv-0002ns-FY for mharc-grub-devel@gnu.org; Wed, 11 Mar 2020 13:38:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33442) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jC5Is-0002hk-MQ for grub-devel@gnu.org; Wed, 11 Mar 2020 13:37:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jC5Ir-0000Ih-FI for grub-devel@gnu.org; Wed, 11 Mar 2020 13:37:58 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44111) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jC5Ir-0000HT-9L for grub-devel@gnu.org; Wed, 11 Mar 2020 13:37:57 -0400 Received: by mail-pg1-x542.google.com with SMTP id 37so1569179pgm.11 for ; Wed, 11 Mar 2020 10:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=delphix.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4YUwo+flaILDew6lSWtZCtwEA+xbxsH4Ase5Dx44tvk=; b=XnwWbDHn3cpGijMWTOrf8KQ8Nd6KAwT7LqaLHph+dviF1CAY61zTkmegVr00rLB08q 8czYwvbyYC9BvNTR3V8cxzNu7yn1fajly7POSacvqMQkrDypx2aguhRB4SkyOAJ3uP36 l0rZrbCgfT/M9wM7OTOW7dGoy0lE4P9jtHuKs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4YUwo+flaILDew6lSWtZCtwEA+xbxsH4Ase5Dx44tvk=; b=O227VcNydKzWKNpfq9IxIecgb4nryNESkpFANKQd9yAbu5XjP9EI7+OdX72FpvzRIx u5jHjeD2SY0Hd1Qy3B5jbJ7AooFckXdrKBVV0OaSy/RjlNqYygJGUM9s8dzQwR+IbPEA +/T3xpZWCo5TGe8znwyfrkqapNMqx10lOJoKJwaGPMyzvUHKAbpAnPSUjMArOOhDuDll a8U4ZbqoDlKPIzsbnejDkZUC6MTt1rRNk3gHKu3j5CyST0jqRpDVODr0eDuGyVy8fiLH ILEBSYc2RrL8Yha3JylTkBtlpNbtrnXmyU5VdgIFJonu/++3+fXt61CPY49ICgmfbak7 O6UA== X-Gm-Message-State: ANhLgQ33o/eogsFcoBCfdkWXzbDC0HJeDqWQf9WhYoBZbiUTOiLagQts Qfec84fuqwoKrXoFinBt5xJYDBY7YGJCZdOevEsLpgg3h3GIygl5N0KYQ6BYcMao1XRTLnKqwYN tlfDsooP02qf2YiP4p35qgMTr/xxMn4UfVMOoBhkY/TF2dI+BNFoxzw== X-Google-Smtp-Source: ADFU+vs03C+YFlkdo17bV9VOuGCtPISDsIL9boNsgMyx6kHskF+8HNSc+ghdvomPZo4W5c3Y0JX9oQ== X-Received: by 2002:a62:8342:: with SMTP id h63mr3927366pfe.24.1583948274964; Wed, 11 Mar 2020 10:37:54 -0700 (PDT) Received: from localhost.localdomain (c-73-162-153-225.hsd1.ca.comcast.net. [73.162.153.225]) by smtp.gmail.com with ESMTPSA id b3sm6342060pjq.38.2020.03.11.10.37.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Mar 2020 10:37:53 -0700 (PDT) From: Paul Dagnelie To: grub-devel@gnu.org Cc: mahrens@delphix.com, behlendorf1@llnl.gov, george.wilson@delphix.com, sebastien.roy@delphix.com, Paul Dagnelie Subject: [PATCH 6/7] Refactor default envblk size out for reuse Date: Wed, 11 Mar 2020 10:37:14 -0700 Message-Id: <20200311173715.22274-7-pcd@delphix.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20200311173715.22274-1-pcd@delphix.com> References: <20200311173715.22274-1-pcd@delphix.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Mar 2020 17:38:00 -0000 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 --- 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 #include -#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