aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-01-07 01:33:54 -0800
committerJunio C Hamano <junkio@cox.net>2006-01-07 10:51:06 -0800
commit8f1d2e6f49ee51ac062ab38337a6a70dd1998def (patch)
tree0054fb58243a1ede631e0d12a0482d37c3476a25
parent3be7098ce444395959c856de1eb9312550193aac (diff)
downloadgit-8f1d2e6f49ee51ac062ab38337a6a70dd1998def.tar.gz
git-8f1d2e6f49ee51ac062ab38337a6a70dd1998def.tar.xz
[PATCH] Compilation: zero-length array declaration.
ISO C99 (and GCC 3.x or later) lets you write a flexible array at the end of a structure, like this: struct frotz { int xyzzy; char nitfol[]; /* more */ }; GCC 2.95 and 2.96 let you to do this with "char nitfol[0]"; unfortunately this is not allowed by ISO C90. This declares such construct like this: struct frotz { int xyzzy; char nitfol[FLEX_ARRAY]; /* more */ }; and git-compat-util.h defines FLEX_ARRAY to 0 for gcc 2.95 and empty for others. If you are using a C90 C compiler, you should be able to override this with CFLAGS=-DFLEX_ARRAY=1 from the command line of "make". Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--blob.c2
-rw-r--r--cache.h9
-rw-r--r--commit.c2
-rw-r--r--git-compat-util.h8
-rw-r--r--ls-files.c2
-rw-r--r--object.c2
-rw-r--r--object.h2
-rw-r--r--receive-pack.c2
-rw-r--r--tag.c2
-rw-r--r--tree.c2
10 files changed, 21 insertions, 12 deletions
diff --git a/blob.c b/blob.c
index ea52ad5c9..84ec1212e 100644
--- a/blob.c
+++ b/blob.c
@@ -1,5 +1,5 @@
-#include "blob.h"
#include "cache.h"
+#include "blob.h"
#include <stdlib.h>
const char *blob_type = "blob";
diff --git a/cache.h b/cache.h
index cb87becb3..5fd268763 100644
--- a/cache.h
+++ b/cache.h
@@ -81,7 +81,7 @@ struct cache_entry {
unsigned int ce_size;
unsigned char sha1[20];
unsigned short ce_flags;
- char name[0];
+ char name[FLEX_ARRAY]; /* more */
};
#define CE_NAMEMASK (0x0fff)
@@ -257,7 +257,7 @@ extern int checkout_entry(struct cache_entry *ce, struct checkout *state);
extern struct alternate_object_database {
struct alternate_object_database *next;
char *name;
- char base[0]; /* more */
+ char base[FLEX_ARRAY]; /* more */
} *alt_odb_list;
extern void prepare_alt_odb(void);
@@ -271,7 +271,8 @@ extern struct packed_git {
unsigned int pack_use_cnt;
int pack_local;
unsigned char sha1[20];
- char pack_name[0]; /* something like ".git/objects/pack/xxxxx.pack" */
+ /* something like ".git/objects/pack/xxxxx.pack" */
+ char pack_name[FLEX_ARRAY]; /* more */
} *packed_git;
struct pack_entry {
@@ -286,7 +287,7 @@ struct ref {
unsigned char new_sha1[20];
unsigned char force;
struct ref *peer_ref; /* when renaming */
- char name[0];
+ char name[FLEX_ARRAY]; /* more */
};
extern int git_connect(int fd[2], char *url, const char *prog);
diff --git a/commit.c b/commit.c
index edd4dedcd..fb02ba609 100644
--- a/commit.c
+++ b/commit.c
@@ -1,6 +1,6 @@
+#include "cache.h"
#include "tag.h"
#include "commit.h"
-#include "cache.h"
int save_commit_buffer = 1;
diff --git a/git-compat-util.h b/git-compat-util.h
index c353b276f..12ce6590b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1,6 +1,14 @@
#ifndef GIT_COMPAT_UTIL_H
#define GIT_COMPAT_UTIL_H
+#ifndef FLEX_ARRAY
+#if defined(__GNUC__) && (__GNUC__ < 3)
+#define FLEX_ARRAY 0
+#else
+#define FLEX_ARRAY /* empty */
+#endif
+#endif
+
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
diff --git a/ls-files.c b/ls-files.c
index cd8743012..74ec8c0ae 100644
--- a/ls-files.c
+++ b/ls-files.c
@@ -208,7 +208,7 @@ static int excluded(const char *pathname)
struct nond_on_fs {
int len;
- char name[0];
+ char name[FLEX_ARRAY]; /* more */
};
static struct nond_on_fs **dir;
diff --git a/object.c b/object.c
index cf5931a94..1577f7428 100644
--- a/object.c
+++ b/object.c
@@ -1,8 +1,8 @@
+#include "cache.h"
#include "object.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
-#include "cache.h"
#include "tag.h"
struct object **objs;
diff --git a/object.h b/object.h
index 336d986b5..0e7618283 100644
--- a/object.h
+++ b/object.h
@@ -9,7 +9,7 @@ struct object_list {
struct object_refs {
unsigned count;
- struct object *ref[0];
+ struct object *ref[FLEX_ARRAY]; /* more */
};
struct object {
diff --git a/receive-pack.c b/receive-pack.c
index 92878ecac..ce986fe11 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -24,7 +24,7 @@ struct command {
unsigned char updated;
unsigned char old_sha1[20];
unsigned char new_sha1[20];
- char ref_name[0];
+ char ref_name[FLEX_ARRAY]; /* more */
};
static struct command *commands = NULL;
diff --git a/tag.c b/tag.c
index 61ac434d6..ac0e57398 100644
--- a/tag.c
+++ b/tag.c
@@ -1,5 +1,5 @@
-#include "tag.h"
#include "cache.h"
+#include "tag.h"
const char *tag_type = "tag";
diff --git a/tree.c b/tree.c
index e7a7b7190..dc1c41e93 100644
--- a/tree.c
+++ b/tree.c
@@ -1,8 +1,8 @@
+#include "cache.h"
#include "tree.h"
#include "blob.h"
#include "commit.h"
#include "tag.h"
-#include "cache.h"
#include <stdlib.h>
const char *tree_type = "tree";