aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-03-09 11:58:05 -0800
committerJunio C Hamano <junkio@cox.net>2006-03-09 11:58:05 -0800
commitb4f2a6ac9263d6e9bf3bf9c8abe607cd6def0ee8 (patch)
tree7956fa207bb2aa7eaee0290c2f8cbf11b1feaf6e
parent7bd7f2804d84258a5cd1e76c610496f6beaa4cdf (diff)
downloadgit-b4f2a6ac9263d6e9bf3bf9c8abe607cd6def0ee8.tar.gz
git-b4f2a6ac9263d6e9bf3bf9c8abe607cd6def0ee8.tar.xz
Use #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--apply.c2
-rw-r--r--date.c4
-rw-r--r--exec_cmd.c2
-rw-r--r--git-compat-util.h2
-rw-r--r--git.c2
5 files changed, 5 insertions, 7 deletions
diff --git a/apply.c b/apply.c
index 849a8b448..179b3bbd0 100644
--- a/apply.c
+++ b/apply.c
@@ -651,7 +651,7 @@ static int parse_git_header(char *line, int len, unsigned int size, struct patch
len = linelen(line, size);
if (!len || line[len-1] != '\n')
break;
- for (i = 0; i < sizeof(optable) / sizeof(optable[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(optable); i++) {
const struct opentry *p = optable + i;
int oplen = strlen(p->str);
if (len < oplen || memcmp(p->str, line, oplen))
diff --git a/date.c b/date.c
index 416ea579a..1c1917b4e 100644
--- a/date.c
+++ b/date.c
@@ -123,8 +123,6 @@ static const struct {
{ "IDLE", +12, 0, }, /* International Date Line East */
};
-#define NR_TZ (sizeof(timezone_names) / sizeof(timezone_names[0]))
-
static int match_string(const char *date, const char *str)
{
int i = 0;
@@ -173,7 +171,7 @@ static int match_alpha(const char *date, struct tm *tm, int *offset)
}
}
- for (i = 0; i < NR_TZ; i++) {
+ for (i = 0; i < ARRAY_SIZE(timezone_names); i++) {
int match = match_string(date, timezone_names[i].name);
if (match >= 3) {
int off = timezone_names[i].offset;
diff --git a/exec_cmd.c b/exec_cmd.c
index 96cc2123b..590e73896 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -37,7 +37,7 @@ int execv_git_cmd(const char **argv)
getenv("GIT_EXEC_PATH"),
builtin_exec_path };
- for (i = 0; i < sizeof(paths)/sizeof(paths[0]); ++i) {
+ for (i = 0; i < ARRAY_SIZE(paths); ++i) {
const char *exec_dir = paths[i];
const char *tmp;
diff --git a/git-compat-util.h b/git-compat-util.h
index f982b8e48..5d543d29f 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -9,6 +9,8 @@
#endif
#endif
+#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
diff --git a/git.c b/git.c
index 164d3e9e4..746e2af68 100644
--- a/git.c
+++ b/git.c
@@ -323,8 +323,6 @@ static int cmd_log(int argc, const char **argv, char **envp)
return 0;
}
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
-
static void handle_internal_command(int argc, const char **argv, char **envp)
{
const char *cmd = argv[0];