All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon McCune <jonmccune@google.com>
To: grub-devel@gnu.org
Cc: Jon McCune <jonmccune@google.com>
Subject: [PATCH v2 1/5] style: indent --no-tabs --gnu-style grub-core/commands/loadenv.c
Date: Fri,  6 Sep 2013 09:18:49 -0700	[thread overview]
Message-ID: <1378484333-13577-2-git-send-email-jonmccune@google.com> (raw)
In-Reply-To: <1378484333-13577-1-git-send-email-jonmccune@google.com>

Added the option --no-tabs after observing that 'indent' did not
result in consistent tab usage.

An example of the inconsistent tab usage: the very first function
in loadenv.c is open_envblk_file(), and it contains a line
indented exclusively with tabs, and lines indented exclusively
with spaces.  The space-idented lines use two spaces for each
level of indentation.  In order for the tab-indented lines to
format properly, the tabs must consume the equivalent of 8
spaces (i.e., four levels of indentation). To my knowledge, this
is not consistent with the default GNU style.

Signed-off-by: Jon McCune <jonmccune@google.com>
---
 grub-core/commands/loadenv.c | 87 ++++++++++++++++++++++----------------------
 1 file changed, 44 insertions(+), 43 deletions(-)

diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
index c0a42c5..a431499 100644
--- a/grub-core/commands/loadenv.c
+++ b/grub-core/commands/loadenv.c
@@ -30,20 +30,19 @@
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
-static const struct grub_arg_option options[] =
-  {
-    /* TRANSLATORS: This option is used to override default filename
-       for loading and storing environment.  */
-    {"file", 'f', 0, N_("Specify filename."), 0, ARG_TYPE_PATHNAME},
-    {0, 0, 0, 0, 0, 0}
-  };
+static const struct grub_arg_option options[] = {
+  /* TRANSLATORS: This option is used to override default filename
+     for loading and storing environment.  */
+  {"file", 'f', 0, N_("Specify filename."), 0, ARG_TYPE_PATHNAME},
+  {0, 0, 0, 0, 0, 0}
+};
 
 static grub_file_t
 open_envblk_file (char *filename)
 {
   grub_file_t file;
 
-  if (! filename)
+  if (!filename)
     {
       const char *prefix;
 
@@ -54,20 +53,21 @@ open_envblk_file (char *filename)
 
           len = grub_strlen (prefix);
           filename = grub_malloc (len + 1 + sizeof (GRUB_ENVBLK_DEFCFG));
-          if (! filename)
+          if (!filename)
             return 0;
 
           grub_strcpy (filename, prefix);
           filename[len] = '/';
           grub_strcpy (filename + len + 1, GRUB_ENVBLK_DEFCFG);
-	  grub_file_filter_disable_compression ();
+          grub_file_filter_disable_compression ();
           file = grub_file_open (filename);
           grub_free (filename);
           return file;
         }
       else
         {
-          grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "prefix");
+          grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
+                      "prefix");
           return 0;
         }
     }
@@ -85,7 +85,7 @@ read_envblk_file (grub_file_t file)
   grub_envblk_t envblk;
 
   buf = grub_malloc (size);
-  if (! buf)
+  if (!buf)
     return 0;
 
   while (size > 0)
@@ -104,7 +104,7 @@ read_envblk_file (grub_file_t file)
     }
 
   envblk = grub_envblk_open (buf, offset);
-  if (! envblk)
+  if (!envblk)
     {
       grub_free (buf);
       grub_error (GRUB_ERR_BAD_FILE_TYPE, "invalid environment block");
@@ -124,25 +124,25 @@ set_var (const char *name, const char *value)
 
 static grub_err_t
 grub_cmd_load_env (grub_extcmd_context_t ctxt,
-		   int argc __attribute__ ((unused)),
-		   char **args __attribute__ ((unused)))
+                   int argc __attribute__ ((unused)),
+                   char **args __attribute__ ((unused)))
 {
   struct grub_arg_list *state = ctxt->state;
   grub_file_t file;
   grub_envblk_t envblk;
 
   file = open_envblk_file ((state[0].set) ? state[0].arg : 0);
-  if (! file)
+  if (!file)
     return grub_errno;
 
   envblk = read_envblk_file (file);
-  if (! envblk)
+  if (!envblk)
     goto fail;
 
   grub_envblk_iterate (envblk, set_var);
   grub_envblk_close (envblk);
 
- fail:
+fail:
   grub_file_close (file);
   return grub_errno;
 }
@@ -157,25 +157,25 @@ print_var (const char *name, const char *value)
 
 static grub_err_t
 grub_cmd_list_env (grub_extcmd_context_t ctxt,
-		   int argc __attribute__ ((unused)),
-		   char **args __attribute__ ((unused)))
+                   int argc __attribute__ ((unused)),
+                   char **args __attribute__ ((unused)))
 {
   struct grub_arg_list *state = ctxt->state;
   grub_file_t file;
   grub_envblk_t envblk;
 
   file = open_envblk_file ((state[0].set) ? state[0].arg : 0);
-  if (! file)
+  if (!file)
     return grub_errno;
 
   envblk = read_envblk_file (file);
-  if (! envblk)
+  if (!envblk)
     goto fail;
 
   grub_envblk_iterate (envblk, print_var);
   grub_envblk_close (envblk);
 
- fail:
+fail:
   grub_file_close (file);
   return grub_errno;
 }
@@ -253,7 +253,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists,
         return grub_errno;
 
       if (grub_memcmp (buf + index, blockbuf, p->length) != 0)
-	return grub_error (GRUB_ERR_FILE_READ_ERROR, "invalid blocklist");
+        return grub_error (GRUB_ERR_FILE_READ_ERROR, "invalid blocklist");
     }
 
   return GRUB_ERR_NONE;
@@ -293,7 +293,7 @@ struct grub_cmd_save_env_ctx
 /* Store blocklists in a linked list.  */
 static void
 save_env_read_hook (grub_disk_addr_t sector, unsigned offset, unsigned length,
-		    void *data)
+                    void *data)
 {
   struct grub_cmd_save_env_ctx *ctx = data;
   struct blocklist *block;
@@ -303,7 +303,7 @@ save_env_read_hook (grub_disk_addr_t sector, unsigned offset, unsigned length,
     return;
 
   block = grub_malloc (sizeof (*block));
-  if (! block)
+  if (!block)
     return;
 
   block->sector = sector;
@@ -315,7 +315,7 @@ save_env_read_hook (grub_disk_addr_t sector, unsigned offset, unsigned length,
   if (ctx->tail)
     ctx->tail->next = block;
   ctx->tail = block;
-  if (! ctx->head)
+  if (!ctx->head)
     ctx->head = block;
 }
 
@@ -330,14 +330,14 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
     .tail = 0
   };
 
-  if (! argc)
+  if (!argc)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "no variable is specified");
 
   file = open_envblk_file ((state[0].set) ? state[0].arg : 0);
-  if (! file)
+  if (!file)
     return grub_errno;
 
-  if (! file->device->disk)
+  if (!file->device->disk)
     {
       grub_file_close (file);
       return grub_error (GRUB_ERR_BAD_DEVICE, "disk device required");
@@ -347,7 +347,7 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
   file->read_hook_data = &ctx;
   envblk = read_envblk_file (file);
   file->read_hook = 0;
-  if (! envblk)
+  if (!envblk)
     goto fail;
 
   if (check_blocklists (envblk, ctx.head, file))
@@ -360,9 +360,10 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
       value = grub_env_get (args[0]);
       if (value)
         {
-          if (! grub_envblk_set (envblk, args[0], value))
+          if (!grub_envblk_set (envblk, args[0], value))
             {
-              grub_error (GRUB_ERR_BAD_ARGUMENT, "environment block too small");
+              grub_error (GRUB_ERR_BAD_ARGUMENT,
+                          "environment block too small");
               goto fail;
             }
         }
@@ -373,7 +374,7 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
 
   write_blocklists (envblk, ctx.head, file);
 
- fail:
+fail:
   if (envblk)
     grub_envblk_close (envblk);
   free_blocklists (ctx.head);
@@ -383,24 +384,24 @@ grub_cmd_save_env (grub_extcmd_context_t ctxt, int argc, char **args)
 
 static grub_extcmd_t cmd_load, cmd_list, cmd_save;
 
-GRUB_MOD_INIT(loadenv)
+GRUB_MOD_INIT (loadenv)
 {
   cmd_load =
     grub_register_extcmd ("load_env", grub_cmd_load_env, 0, N_("[-f FILE]"),
-			  N_("Load variables from environment block file."),
-			  options);
+                          N_("Load variables from environment block file."),
+                          options);
   cmd_list =
     grub_register_extcmd ("list_env", grub_cmd_list_env, 0, N_("[-f FILE]"),
-			  N_("List variables from environment block file."),
-			  options);
+                          N_("List variables from environment block file."),
+                          options);
   cmd_save =
     grub_register_extcmd ("save_env", grub_cmd_save_env, 0,
-			  N_("[-f FILE] variable_name [...]"),
-			  N_("Save variables to environment block file."),
-			  options);
+                          N_("[-f FILE] variable_name [...]"),
+                          N_("Save variables to environment block file."),
+                          options);
 }
 
-GRUB_MOD_FINI(loadenv)
+GRUB_MOD_FINI (loadenv)
 {
   grub_unregister_extcmd (cmd_load);
   grub_unregister_extcmd (cmd_list);
-- 
1.8.4



  reply	other threads:[~2013-09-06 16:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-06 16:18 [PATCH v2 0/5] Enable savedefault, etc with check_signatures=enforce Jon McCune
2013-09-06 16:18 ` Jon McCune [this message]
2013-09-06 16:18 ` [PATCH v2 2/5] load_env support for whitelisting which variables are read from an env file, even if check_signatures=enforce Jon McCune
2013-09-06 19:48   ` Andrey Borzenkov
2013-09-06 21:10     ` Jonathan McCune
2013-09-07  9:33       ` Andrey Borzenkov
2013-09-09 15:34         ` Jonathan McCune
2013-09-19 10:12           ` Andrey Borzenkov
2013-09-19 18:18             ` Jonathan McCune
2013-09-19  7:18         ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-09-19 10:06           ` Andrey Borzenkov
2013-09-06 16:18 ` [PATCH v2 3/5] save_env should work, " Jon McCune
2013-09-06 16:18 ` [PATCH v2 4/5] Add -k, --pubkey=FILE support to grub-install command Jon McCune
2013-09-06 19:40   ` Andrey Borzenkov
2013-09-06 21:10     ` Jonathan McCune
2013-09-06 16:18 ` [PATCH v2 5/5] Additional security-relevant documentation Jon McCune

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1378484333-13577-2-git-send-email-jonmccune@google.com \
    --to=jonmccune@google.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.