{"thread":{"id":"17518","subject":"[PATCH] Style cleanup - When declaring pointers the star sides with the variable","startedAt":"2009-02-03T01:21:12Z","lastAt":"2009-02-03T01:21:12Z","messageCount":1,"participants":["Bernt Hansen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"102909","messageId":"87pri0co3b.fsf@gollum.intra.norang.ca","threadId":"17518","inReplyTo":null,"subject":"[PATCH] Style cleanup - When declaring pointers the star sides with the variable","fromName":"Bernt Hansen","fromEmail":"bernt@norang.ca","sentAt":"2009-02-03T01:21:12Z","receivedAt":"2009-02-03T01:21:12Z","isPatch":true,"sender":{"key":"bernt@norang.ca","avatar":null},"body":">From Documentation/CodingGuidelines:\n\n - When declaring pointers, the star sides with the variable\n   name, i.e. \"char *string\", not \"char* string\" or\n   \"char * string\".  This makes it easier to understand code\n   like \"char *string, c;\".\n\nSigned-off-by: Bernt Hansen <bernt@norang.ca>\n---\n\nHere is a cleanup patch for all of the cases I could find.  I skipped\nhttp.c since Junio already submitted a patch that covers that in\nhttp://permalink.gmane.org/gmane.comp.version-control.git/108054\n\n-Bernt\n\n alloc.c                  |    2 +-\n builtin-check-attr.c     |    4 ++--\n builtin-checkout-index.c |    2 +-\n builtin-config.c         |    6 +++---\n builtin-fast-export.c    |    2 +-\n builtin-fetch-pack.c     |    2 +-\n builtin-help.c           |    6 +++---\n commit.c                 |    2 +-\n config.c                 |   28 ++++++++++++++--------------\n diff.c                   |    6 +++---\n fast-import.c            |   34 +++++++++++++++++-----------------\n git.c                    |    4 ++--\n quote.c                  |    2 +-\n reflog-walk.c            |    6 +++---\n sha1_file.c              |   14 +++++++-------\n wt-status.c              |    2 +-\n 16 files changed, 61 insertions(+), 61 deletions(-)\n\ndiff --git a/alloc.c b/alloc.c\nindex 216c23a..6ef6753 100644\n--- a/alloc.c\n+++ b/alloc.c\n@@ -57,7 +57,7 @@ DEFINE_ALLOCATOR(object, union any_object)\n #define SZ_FMT \"%zu\"\n #endif\n \n-static void report(const char* name, unsigned int count, size_t size)\n+static void report(const char *name, unsigned int count, size_t size)\n {\n     fprintf(stderr, \"%10s: %8u (\" SZ_FMT \" kB)\\n\", name, count, size);\n }\ndiff --git a/builtin-check-attr.c b/builtin-check-attr.c\nindex 15a04b7..abcf767 100644\n--- a/builtin-check-attr.c\n+++ b/builtin-check-attr.c\n@@ -21,7 +21,7 @@ static const struct option check_attr_options[] = {\n };\n \n static void check_attr(int cnt, struct git_attr_check *check,\n-\tconst char** name, const char *file)\n+\tconst char **name, const char *file)\n {\n \tint j;\n \tif (git_checkattr(file, cnt, check))\n@@ -42,7 +42,7 @@ static void check_attr(int cnt, struct git_attr_check *check,\n }\n \n static void check_attr_stdin_paths(int cnt, struct git_attr_check *check,\n-\tconst char** name)\n+\tconst char **name)\n {\n \tstruct strbuf buf, nbuf;\n \tint line_termination = null_term_line ? 0 : '\\n';\ndiff --git a/builtin-checkout-index.c b/builtin-checkout-index.c\nindex 0d534bc..88d3314 100644\n--- a/builtin-checkout-index.c\n+++ b/builtin-checkout-index.c\n@@ -124,7 +124,7 @@ static int checkout_file(const char *name, int prefix_length)\n static void checkout_all(const char *prefix, int prefix_length)\n {\n \tint i, errs = 0;\n-\tstruct cache_entry* last_ce = NULL;\n+\tstruct cache_entry *last_ce = NULL;\n \n \tfor (i = 0; i < active_nr ; i++) {\n \t\tstruct cache_entry *ce = active_cache[i];\ndiff --git a/builtin-config.c b/builtin-config.c\nindex f710162..1582673 100644\n--- a/builtin-config.c\n+++ b/builtin-config.c\n@@ -27,7 +27,7 @@ static int show_all_config(const char *key_, const char *value_, void *cb)\n \treturn 0;\n }\n \n-static int show_config(const char* key_, const char* value_, void *cb)\n+static int show_config(const char *key_, const char *value_, void *cb)\n {\n \tchar value[256];\n \tconst char *vptr = value;\n@@ -74,7 +74,7 @@ static int show_config(const char* key_, const char* value_, void *cb)\n \treturn 0;\n }\n \n-static int get_value(const char* key_, const char* regex_)\n+static int get_value(const char *key_, const char *regex_)\n {\n \tint ret = -1;\n \tchar *tl;\n@@ -284,7 +284,7 @@ static int get_colorbool(int argc, const char **argv)\n int cmd_config(int argc, const char **argv, const char *prefix)\n {\n \tint nongit;\n-\tchar* value;\n+\tchar *value;\n \tconst char *file = setup_git_directory_gently(&nongit);\n \n \tconfig_exclusive_filename = getenv(CONFIG_ENVIRONMENT);\ndiff --git a/builtin-fast-export.c b/builtin-fast-export.c\nindex e9ee2c7..56b3cce 100644\n--- a/builtin-fast-export.c\n+++ b/builtin-fast-export.c\n@@ -62,7 +62,7 @@ static inline uint32_t *mark_to_ptr(uint32_t mark)\n \treturn ((uint32_t *)NULL) + mark;\n }\n \n-static inline uint32_t ptr_to_mark(void * mark)\n+static inline uint32_t ptr_to_mark(void *mark)\n {\n \treturn (uint32_t *)mark - (uint32_t *)NULL;\n }\ndiff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c\nindex 67fb80e..98cbd75 100644\n--- a/builtin-fetch-pack.c\n+++ b/builtin-fetch-pack.c\n@@ -111,7 +111,7 @@ static void mark_common(struct commit *commit,\n   Get the next rev to send, ignoring the common.\n */\n \n-static const unsigned char* get_rev(void)\n+static const unsigned char *get_rev(void)\n {\n \tstruct commit *commit = NULL;\n \ndiff --git a/builtin-help.c b/builtin-help.c\nindex 9b57a74..d3e7e90 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -114,7 +114,7 @@ static int check_emacsclient_version(void)\n \treturn 0;\n }\n \n-static void exec_woman_emacs(const char* path, const char *page)\n+static void exec_woman_emacs(const char *path, const char *page)\n {\n \tif (!check_emacsclient_version()) {\n \t\t/* This works only with emacsclient version >= 22. */\n@@ -128,7 +128,7 @@ static void exec_woman_emacs(const char* path, const char *page)\n \t}\n }\n \n-static void exec_man_konqueror(const char* path, const char *page)\n+static void exec_man_konqueror(const char *path, const char *page)\n {\n \tconst char *display = getenv(\"DISPLAY\");\n \tif (display && *display) {\n@@ -156,7 +156,7 @@ static void exec_man_konqueror(const char* path, const char *page)\n \t}\n }\n \n-static void exec_man_man(const char* path, const char *page)\n+static void exec_man_man(const char *path, const char *page)\n {\n \tif (!path)\n \t\tpath = \"man\";\ndiff --git a/commit.c b/commit.c\nindex aa3b35b..bce9c1b 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -423,7 +423,7 @@ struct commit *pop_commit(struct commit_list **stack)\n /*\n  * Performs an in-place topological sort on the list supplied.\n  */\n-void sort_in_topological_order(struct commit_list ** list, int lifo)\n+void sort_in_topological_order(struct commit_list **list, int lifo)\n {\n \tstruct commit_list *next, *orig = *list;\n \tstruct commit_list *work, **insert;\ndiff --git a/config.c b/config.c\nindex 790405a..35c611d 100644\n--- a/config.c\n+++ b/config.c\n@@ -665,16 +665,16 @@ int git_config(config_fn_t fn, void *data)\n \n static struct {\n \tint baselen;\n-\tchar* key;\n+\tchar *key;\n \tint do_not_match;\n-\tregex_t* value_regex;\n+\tregex_t *value_regex;\n \tint multi_replace;\n \tsize_t offset[MAX_MATCHES];\n \tenum { START, SECTION_SEEN, SECTION_END_SEEN, KEY_SEEN } state;\n \tint seen;\n } store;\n \n-static int matches(const char* key, const char* value)\n+static int matches(const char *key, const char *value)\n {\n \treturn !strcmp(key, store.key) &&\n \t\t(store.value_regex == NULL ||\n@@ -682,7 +682,7 @@ static int matches(const char* key, const char* value)\n \t\t  !regexec(store.value_regex, value, 0, NULL, 0)));\n }\n \n-static int store_aux(const char* key, const char* value, void *cb)\n+static int store_aux(const char *key, const char *value, void *cb)\n {\n \tconst char *ep;\n \tsize_t section_len;\n@@ -751,7 +751,7 @@ static int write_error(const char *filename)\n \treturn 4;\n }\n \n-static int store_write_section(int fd, const char* key)\n+static int store_write_section(int fd, const char *key)\n {\n \tconst char *dot;\n \tint i, success;\n@@ -776,7 +776,7 @@ static int store_write_section(int fd, const char* key)\n \treturn success;\n }\n \n-static int store_write_pair(int fd, const char* key, const char* value)\n+static int store_write_pair(int fd, const char *key, const char *value)\n {\n \tint i, success;\n \tint length = strlen(key + store.baselen + 1);\n@@ -824,7 +824,7 @@ static int store_write_pair(int fd, const char* key, const char* value)\n \treturn success;\n }\n \n-static ssize_t find_beginning_of_line(const char* contents, size_t size,\n+static ssize_t find_beginning_of_line(const char *contents, size_t size,\n \tsize_t offset_, int* found_bracket)\n {\n \tsize_t equal_offset = size, bracket_offset = size;\n@@ -850,7 +850,7 @@ contline:\n \treturn offset;\n }\n \n-int git_config_set(const char* key, const char* value)\n+int git_config_set(const char *key, const char *value)\n {\n \treturn git_config_set_multivar(key, value, NULL, 0);\n }\n@@ -878,15 +878,15 @@ int git_config_set(const char* key, const char* value)\n  * - the config file is removed and the lock file rename()d to it.\n  *\n  */\n-int git_config_set_multivar(const char* key, const char* value,\n-\tconst char* value_regex, int multi_replace)\n+int git_config_set_multivar(const char *key, const char *value,\n+\t\t\t    const char *value_regex, int multi_replace)\n {\n \tint i, dot;\n \tint fd = -1, in_fd;\n \tint ret;\n-\tchar* config_filename;\n+\tchar *config_filename;\n \tstruct lock_file *lock = NULL;\n-\tconst char* last_dot = strrchr(key, '.');\n+\tconst char *last_dot = strrchr(key, '.');\n \n \tif (config_exclusive_filename)\n \t\tconfig_filename = xstrdup(config_exclusive_filename);\n@@ -967,13 +967,13 @@ int git_config_set_multivar(const char* key, const char* value,\n \t\t\tgoto out_free;\n \t\t}\n \n-\t\tstore.key = (char*)key;\n+\t\tstore.key = (char *)key;\n \t\tif (!store_write_section(fd, key) ||\n \t\t    !store_write_pair(fd, key, value))\n \t\t\tgoto write_err_out;\n \t} else {\n \t\tstruct stat st;\n-\t\tchar* contents;\n+\t\tchar *contents;\n \t\tsize_t contents_sz, copy_begin, copy_end;\n \t\tint i, new_line = 0;\n \ndiff --git a/diff.c b/diff.c\nindex a5a540f..34d0543 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -873,7 +873,7 @@ static void fill_print_name(struct diffstat_file *file)\n \tfile->print_name = pname;\n }\n \n-static void show_stats(struct diffstat_t* data, struct diff_options *options)\n+static void show_stats(struct diffstat_t *data, struct diff_options *options)\n {\n \tint i, len, add, del, total, adds = 0, dels = 0;\n \tint max_change = 0, max_len = 0;\n@@ -999,7 +999,7 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)\n \t       set, total_files, adds, dels, reset);\n }\n \n-static void show_shortstats(struct diffstat_t* data, struct diff_options *options)\n+static void show_shortstats(struct diffstat_t *data, struct diff_options *options)\n {\n \tint i, adds = 0, dels = 0, total_files = data->nr;\n \n@@ -1024,7 +1024,7 @@ static void show_shortstats(struct diffstat_t* data, struct diff_options *option\n \t       total_files, adds, dels);\n }\n \n-static void show_numstat(struct diffstat_t* data, struct diff_options *options)\n+static void show_numstat(struct diffstat_t *data, struct diff_options *options)\n {\n \tint i;\n \ndiff --git a/fast-import.c b/fast-import.c\nindex 1935206..50b17b8 100644\n--- a/fast-import.c\n+++ b/fast-import.c\n@@ -211,7 +211,7 @@ struct tree_content;\n struct tree_entry\n {\n \tstruct tree_content *tree;\n-\tstruct atom_str* name;\n+\tstruct atom_str *name;\n \tstruct tree_entry_ms\n \t{\n \t\tuint16_t mode;\n@@ -312,7 +312,7 @@ static unsigned int object_entry_alloc = 5000;\n static struct object_entry_pool *blocks;\n static struct object_entry *object_table[1 << 16];\n static struct mark_set *marks;\n-static const char* mark_file;\n+static const char *mark_file;\n \n /* Our last blob */\n static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };\n@@ -671,7 +671,7 @@ static struct branch *lookup_branch(const char *name)\n static struct branch *new_branch(const char *name)\n {\n \tunsigned int hc = hc_str(name, strlen(name)) % branch_table_sz;\n-\tstruct branch* b = lookup_branch(name);\n+\tstruct branch *b = lookup_branch(name);\n \n \tif (b)\n \t\tdie(\"Invalid attempt to create duplicate branch: %s\", name);\n@@ -839,8 +839,8 @@ static void start_packfile(void)\n \n static int oecmp (const void *a_, const void *b_)\n {\n-\tstruct object_entry *a = *((struct object_entry**)a_);\n-\tstruct object_entry *b = *((struct object_entry**)b_);\n+\tstruct object_entry *a = *((struct object_entry **)a_);\n+\tstruct object_entry *b = *((struct object_entry **)b_);\n \treturn hashcmp(a->sha1, b->sha1);\n }\n \n@@ -855,7 +855,7 @@ static char *create_index(void)\n \tint i, idx_fd;\n \n \t/* Build the sorted table of object IDs. */\n-\tidx = xmalloc(object_count * sizeof(struct object_entry*));\n+\tidx = xmalloc(object_count * sizeof(struct object_entry *));\n \tc = idx;\n \tfor (o = blocks; o; o = o->next_pool)\n \t\tfor (e = o->next_free; e-- != o->entries;)\n@@ -864,7 +864,7 @@ static char *create_index(void)\n \tlast = idx + object_count;\n \tif (c != last)\n \t\tdie(\"internal consistency error creating the index\");\n-\tqsort(idx, object_count, sizeof(struct object_entry*), oecmp);\n+\tqsort(idx, object_count, sizeof(struct object_entry *), oecmp);\n \n \t/* Generate the fan-out array. */\n \tc = idx;\n@@ -1040,7 +1040,7 @@ static int store_object(\n \tgit_SHA_CTX c;\n \tz_stream s;\n \n-\thdrlen = sprintf((char*)hdr,\"%s %lu\", typename(type),\n+\thdrlen = sprintf((char *)hdr,\"%s %lu\", typename(type),\n \t\t(unsigned long)dat->len) + 1;\n \tgit_SHA1_Init(&c);\n \tgit_SHA1_Update(&c, hdr, hdrlen);\n@@ -1222,7 +1222,7 @@ static const char *get_mode(const char *str, uint16_t *modep)\n \n static void load_tree(struct tree_entry *root)\n {\n-\tunsigned char* sha1 = root->versions[1].sha1;\n+\tunsigned char *sha1 = root->versions[1].sha1;\n \tstruct object_entry *myoe;\n \tstruct tree_content *t;\n \tunsigned long size;\n@@ -1263,8 +1263,8 @@ static void load_tree(struct tree_entry *root)\n \t\te->versions[0].mode = e->versions[1].mode;\n \t\te->name = to_atom(c, strlen(c));\n \t\tc += e->name->str_len + 1;\n-\t\thashcpy(e->versions[0].sha1, (unsigned char*)c);\n-\t\thashcpy(e->versions[1].sha1, (unsigned char*)c);\n+\t\thashcpy(e->versions[0].sha1, (unsigned char *)c);\n+\t\thashcpy(e->versions[1].sha1, (unsigned char *)c);\n \t\tc += 20;\n \t}\n \tfree(buf);\n@@ -1272,8 +1272,8 @@ static void load_tree(struct tree_entry *root)\n \n static int tecmp0 (const void *_a, const void *_b)\n {\n-\tstruct tree_entry *a = *((struct tree_entry**)_a);\n-\tstruct tree_entry *b = *((struct tree_entry**)_b);\n+\tstruct tree_entry *a = *((struct tree_entry **)_a);\n+\tstruct tree_entry *b = *((struct tree_entry **)_b);\n \treturn base_name_compare(\n \t\ta->name->str_dat, a->name->str_len, a->versions[0].mode,\n \t\tb->name->str_dat, b->name->str_len, b->versions[0].mode);\n@@ -1281,8 +1281,8 @@ static int tecmp0 (const void *_a, const void *_b)\n \n static int tecmp1 (const void *_a, const void *_b)\n {\n-\tstruct tree_entry *a = *((struct tree_entry**)_a);\n-\tstruct tree_entry *b = *((struct tree_entry**)_b);\n+\tstruct tree_entry *a = *((struct tree_entry **)_a);\n+\tstruct tree_entry *b = *((struct tree_entry **)_b);\n \treturn base_name_compare(\n \t\ta->name->str_dat, a->name->str_len, a->versions[1].mode,\n \t\tb->name->str_dat, b->name->str_len, b->versions[1].mode);\n@@ -2416,8 +2416,8 @@ int main(int argc, const char **argv)\n \n \talloc_objects(object_entry_alloc);\n \tstrbuf_init(&command_buf, 0);\n-\tatom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*));\n-\tbranch_table = xcalloc(branch_table_sz, sizeof(struct branch*));\n+\tatom_table = xcalloc(atom_table_sz, sizeof(struct atom_str *));\n+\tbranch_table = xcalloc(branch_table_sz, sizeof(struct branch *));\n \tavail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*));\n \tmarks = pool_calloc(1, sizeof(struct mark_set));\n \ndiff --git a/git.c b/git.c\nindex 320cb43..2c3f894 100644\n--- a/git.c\n+++ b/git.c\n@@ -46,7 +46,7 @@ static void commit_pager_choice(void) {\n \t}\n }\n \n-static int handle_options(const char*** argv, int* argc, int* envchanged)\n+static int handle_options(const char ***argv, int *argc, int *envchanged)\n {\n \tint handled = 0;\n \n@@ -132,7 +132,7 @@ static int handle_alias(int *argcp, const char ***argv)\n \tint envchanged = 0, ret = 0, saved_errno = errno;\n \tconst char *subdir;\n \tint count, option_count;\n-\tconst char** new_argv;\n+\tconst char **new_argv;\n \tconst char *alias_command;\n \tchar *alias_string;\n \tint unused_nongit;\ndiff --git a/quote.c b/quote.c\nindex 6a52085..c5c2fa7 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -58,7 +58,7 @@ void sq_quote_print(FILE *stream, const char *src)\n \tfputc('\\'', stream);\n }\n \n-void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)\n+void sq_quote_argv(struct strbuf *dst, const char **argv, size_t maxlen)\n {\n \tint i;\n \ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex f751fdc..05a7696 100644\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -131,7 +131,7 @@ struct reflog_walk_info {\n \tstruct commit_reflog *last_commit_reflog;\n };\n \n-void init_reflog_walk(struct reflog_walk_info** info)\n+void init_reflog_walk(struct reflog_walk_info **info)\n {\n \t*info = xcalloc(sizeof(struct reflog_walk_info), 1);\n }\n@@ -241,8 +241,8 @@ void fake_reflog_parent(struct reflog_walk_info *info, struct commit *commit)\n \tcommit->object.flags &= ~(ADDED | SEEN | SHOWN);\n }\n \n-void show_reflog_message(struct reflog_walk_info* info, int oneline,\n-\tint relative_date)\n+void show_reflog_message(struct reflog_walk_info *info, int oneline,\n+\t\t\t int relative_date)\n {\n \tif (info && info->last_commit_reflog) {\n \t\tstruct commit_reflog *commit_reflog = info->last_commit_reflog;\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 8868b80..09fc4a8 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -235,7 +235,7 @@ char *sha1_pack_index_name(const unsigned char *sha1)\n struct alternate_object_database *alt_odb_list;\n static struct alternate_object_database **alt_odb_tail;\n \n-static void read_info_alternates(const char * alternates, int depth);\n+static void read_info_alternates(const char *alternates, int depth);\n \n /*\n  * Prepare alternate object database registry.\n@@ -252,7 +252,7 @@ static void read_info_alternates(const char * alternates, int depth);\n  * SHA1, an extra slash for the first level indirection, and the\n  * terminating NUL.\n  */\n-static int link_alt_odb_entry(const char * entry, int len, const char * relative_base, int depth)\n+static int link_alt_odb_entry(const char *entry, int len, const char *relative_base, int depth)\n {\n \tconst char *objdir = get_object_directory();\n \tstruct alternate_object_database *ent;\n@@ -356,7 +356,7 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,\n \t}\n }\n \n-static void read_info_alternates(const char * relative_base, int depth)\n+static void read_info_alternates(const char *relative_base, int depth)\n {\n \tchar *map;\n \tsize_t mapsz;\n@@ -790,10 +790,10 @@ static int in_window(struct pack_window *win, off_t offset)\n \t\t&& (offset + 20) <= (win_off + win->len);\n }\n \n-unsigned char* use_pack(struct packed_git *p,\n-\t\tstruct pack_window **w_cursor,\n-\t\toff_t offset,\n-\t\tunsigned int *left)\n+unsigned char *use_pack(struct packed_git *p,\n+\t\t\tstruct pack_window **w_cursor,\n+\t\t\toff_t offset,\n+\t\t\tunsigned int *left)\n {\n \tstruct pack_window *win = *w_cursor;\n \ndiff --git a/wt-status.c b/wt-status.c\nindex 96ff2f8..ac6246e 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -40,7 +40,7 @@ static int parse_status_slot(const char *var, int offset)\n \tdie(\"bad config variable '%s'\", var);\n }\n \n-static const char* color(int slot)\n+static const char *color(int slot)\n {\n \treturn wt_status_use_color > 0 ? wt_status_colors[slot] : \"\";\n }\n-- \n1.6.1.2.310.gdba4a\n"}]}