Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VI5wE-0000XC-9P for mharc-grub-devel@gnu.org; Fri, 06 Sep 2013 19:59:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI5wB-0000Si-08 for grub-devel@gnu.org; Fri, 06 Sep 2013 19:59:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VI5w9-0002hD-Iq for grub-devel@gnu.org; Fri, 06 Sep 2013 19:59:38 -0400 Received: from mail-vb0-x249.google.com ([2607:f8b0:400c:c02::249]:34975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI5w9-0002h4-Ce for grub-devel@gnu.org; Fri, 06 Sep 2013 19:59:37 -0400 Received: by mail-vb0-f73.google.com with SMTP id e12so454366vbg.0 for ; Fri, 06 Sep 2013 16:59:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o/LYy6kaHbqw6bXstLN080njdh3To5UW6jBhwNuW8pc=; b=RiZOA6+9ddb7T6k7uSj6FjSdzaqP+Wh37PGmpjC7JE63CbBmYSFFWslyNyEi0OiSi+ xthO8izIs4IMd+KLLWJFm6ousprar1G6BuNDNqgEq8MiUVB63Ae+eJ2mC0zB5DkzS1CD 2CcwuWX7c0ylnihvpj/uCBiBJxWLRL+pctJa0qMDIxZDiiJlpU/tiKYgV4DX254QL9Rl qUrg3qPu6MdjyuixYJota1oEqdZT/FdL0yQDLiKQfFbMUqDjyv2DUcV2j4ZSDBg+Ynij e0K6rJBA5RqCr0chAWzNngOaUA9Qj9FRN6nM9TNRMIlBB2exlpHI691eXX5A5KsgkbaH BiKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o/LYy6kaHbqw6bXstLN080njdh3To5UW6jBhwNuW8pc=; b=R07s7ozZDEMXB+YaEIUGm+/R4pAFftgqVfgHLesUVhtIh4HS3+2iRT6Z1xkr9JtGIC VyYDznQ6BAiTJKKssmyJMysmQH93Zac9zPRWFTE4CglkIFKCGTHSSokXAFU+eP+6DrpE zLs/cYaBZCRoDrNUSH4iS0nyGz0E+J50zB5ZAp/Kq4zqZesHVwzveJ57uXWtEZ+Tw6VU 8tJrB3zmDfrWDucnLJmBKESPeMjFq5uxZm4Jweh0nLXKRWIRPnNdNVmdTJq0CKS/5Ro/ 8j+E/AR11StiHBoJgHqY5PclReHI5/NJwDdfYEkKX6P8UaB2WanCG7CZMq/ZCcBBV1Pw soow== X-Gm-Message-State: ALoCoQnNCgl6iKQC4XDnZK8jM5CtR489igEYcnVQuNHFi9rISxBec/za3m1Zql0phE5aIVkEE/8Eqq7hXsdCR9lW2QLRXW/d3OO6BST+DbrN5x9X51tV99ZKYbhHyqAYbiacVSBMlchtGXuWF97c+VxfONl0HZUo1INBukF0X+LaJ5KsnWFkEmOhUPBF7b9xNzBFTx1qOHiI9X8Xx5kE6o6Asfy4SqHLzp3Si2chzDHIG2iNSzji5nw= X-Received: by 10.236.103.97 with SMTP id e61mr1705114yhg.31.1378511976756; Fri, 06 Sep 2013 16:59:36 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id z45si17981yha.7.1969.12.31.16.00.00 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Fri, 06 Sep 2013 16:59:36 -0700 (PDT) Received: from yinz.mtv.corp.google.com (yinz.mtv.corp.google.com [172.17.81.122]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 8819A5A41A3; Fri, 6 Sep 2013 16:59:36 -0700 (PDT) Received: by yinz.mtv.corp.google.com (Postfix, from userid 184367) id 487A5C0763; Fri, 6 Sep 2013 16:59:36 -0700 (PDT) From: Jon McCune To: grub-devel@gnu.org Subject: [PATCH v3 1/3] style: indent --no-tabs --gnu-style grub-core/commands/loadenv.c Date: Fri, 6 Sep 2013 16:59:16 -0700 Message-Id: <1378511958-19974-2-git-send-email-jonmccune@google.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1378511958-19974-1-git-send-email-jonmccune@google.com> References: <1378511958-19974-1-git-send-email-jonmccune@google.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c02::249 Cc: Jon McCune X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Sep 2013 23:59:40 -0000 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 --- 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