From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 1/4] attr.c: rename global var attr_nr to git_attr_nr
Date: Tue, 9 Dec 2014 20:53:22 +0700 [thread overview]
Message-ID: <1418133205-18213-2-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1418133205-18213-1-git-send-email-pclouds@gmail.com>
This name "attr_nr" is used elsewhere as local variable, shadowing the
global one. Let's rename the global one into something else to avoid
accidents due to shadow in future.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
attr.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/attr.c b/attr.c
index cd54697..583d36a 100644
--- a/attr.c
+++ b/attr.c
@@ -34,7 +34,7 @@ struct git_attr {
int attr_nr;
char name[FLEX_ARRAY];
};
-static int attr_nr;
+static int git_attr_nr;
static struct git_attr_check *check_all_attr;
static struct git_attr *(git_attr_hash[HASHSIZE]);
@@ -94,10 +94,10 @@ static struct git_attr *git_attr_internal(const char *name, int len)
a->name[len] = 0;
a->h = hval;
a->next = git_attr_hash[pos];
- a->attr_nr = attr_nr++;
+ a->attr_nr = git_attr_nr++;
git_attr_hash[pos] = a;
- REALLOC_ARRAY(check_all_attr, attr_nr);
+ REALLOC_ARRAY(check_all_attr, git_attr_nr);
check_all_attr[a->attr_nr].attr = a;
check_all_attr[a->attr_nr].value = ATTR__UNKNOWN;
return a;
@@ -730,10 +730,10 @@ static void collect_all_attrs(const char *path)
}
prepare_attr_stack(path, dirlen);
- for (i = 0; i < attr_nr; i++)
+ for (i = 0; i < git_attr_nr; i++)
check_all_attr[i].value = ATTR__UNKNOWN;
- rem = attr_nr;
+ rem = git_attr_nr;
for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
rem = fill(path, pathlen, basename_offset, stk, rem);
}
@@ -762,7 +762,7 @@ int git_all_attrs(const char *path, int *num, struct git_attr_check **check)
/* Count the number of attributes that are set. */
count = 0;
- for (i = 0; i < attr_nr; i++) {
+ for (i = 0; i < git_attr_nr; i++) {
const char *value = check_all_attr[i].value;
if (value != ATTR__UNSET && value != ATTR__UNKNOWN)
++count;
@@ -770,7 +770,7 @@ int git_all_attrs(const char *path, int *num, struct git_attr_check **check)
*num = count;
*check = xmalloc(sizeof(**check) * count);
j = 0;
- for (i = 0; i < attr_nr; i++) {
+ for (i = 0; i < git_attr_nr; i++) {
const char *value = check_all_attr[i].value;
if (value != ATTR__UNSET && value != ATTR__UNKNOWN) {
(*check)[j].attr = check_all_attr[i].attr;
--
2.2.0.84.ge9c7a8a
next prev parent reply other threads:[~2014-12-09 13:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-09 13:53 [PATCH/RFC 0/4] some attr optimizations Nguyễn Thái Ngọc Duy
2014-12-09 13:53 ` Nguyễn Thái Ngọc Duy [this message]
2014-12-09 23:54 ` [PATCH 1/4] attr.c: rename global var attr_nr to git_attr_nr Junio C Hamano
2014-12-09 13:53 ` [PATCH 2/4] attr.c: split path processing code out of collect_all_attrs() Nguyễn Thái Ngọc Duy
2014-12-09 13:53 ` [PATCH/RFC 3/4] attr: do not attempt to expand when we know it's not a macro Nguyễn Thái Ngọc Duy
2014-12-09 23:27 ` Eric Sunshine
2014-12-09 23:56 ` Junio C Hamano
2014-12-09 13:53 ` [PATCH/RFC 4/4] attr: avoid heavy work when we know the specified attr is not defined Nguyễn Thái Ngọc Duy
2014-12-10 0:18 ` Junio C Hamano
2014-12-15 0:50 ` Duy Nguyen
2014-12-15 17:30 ` Junio C Hamano
2014-12-27 23:39 ` [PATCH v2 0/3] some attr optimizations Nguyễn Thái Ngọc Duy
2014-12-27 23:39 ` [PATCH v2 1/3] attr.c: rename arg name attr_nr to avoid shadowing the global one Nguyễn Thái Ngọc Duy
2014-12-27 23:39 ` [PATCH v2 2/3] attr: do not attempt to expand when we know it's not a macro Nguyễn Thái Ngọc Duy
2014-12-27 23:59 ` Eric Sunshine
2014-12-27 23:39 ` [PATCH v2 3/3] attr: avoid heavy work when we know the specified attr is not defined Nguyễn Thái Ngọc Duy
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=1418133205-18213-2-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.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.