Commit 1e5dd572 by Ramsay Jones

Fix some coding style issues

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
parent 74eff33f
...@@ -34,7 +34,7 @@ extern int git__fsync(int fd); ...@@ -34,7 +34,7 @@ extern int git__fsync(int fd);
# ifndef GIT__WIN32_NO_HIDE_FILEOPS # ifndef GIT__WIN32_NO_HIDE_FILEOPS
# define unlink(p) git__unlink(p) # define unlink(p) git__unlink(p)
# define mkstemp(t) git__mkstemp(t) # define mkstemp(t) git__mkstemp(t)
# define mkdir(p,m) git__mkdir(p,m) # define mkdir(p,m) git__mkdir(p, m)
# define fsync(fd) git__fsync(fd) # define fsync(fd) git__fsync(fd)
# endif # endif
#endif /* GIT_WIN32 */ #endif /* GIT_WIN32 */
......
...@@ -25,14 +25,14 @@ typedef struct git_commit git_commit; ...@@ -25,14 +25,14 @@ typedef struct git_commit git_commit;
* pool's git_odb, or if the commit is present but is * pool's git_odb, or if the commit is present but is
* too malformed to be parsed successfully. * too malformed to be parsed successfully.
*/ */
GIT_EXTERN(git_commit*) git_commit_parse(git_revpool *pool, const git_oid *id); GIT_EXTERN(git_commit *) git_commit_parse(git_revpool *pool, const git_oid *id);
/** /**
* Get the id of a commit. * Get the id of a commit.
* @param commit a previously parsed commit. * @param commit a previously parsed commit.
* @return object identity for the commit. * @return object identity for the commit.
*/ */
GIT_EXTERN(const git_oid*) git_commit_id(git_commit *commit); GIT_EXTERN(const git_oid *) git_commit_id(git_commit *commit);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL
......
...@@ -20,8 +20,7 @@ GIT_BEGIN_DECL ...@@ -20,8 +20,7 @@ GIT_BEGIN_DECL
#define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2) #define GIT_OID_HEXSZ (GIT_OID_RAWSZ * 2)
/** Unique identity of any object (commit, tree, blob, tag). */ /** Unique identity of any object (commit, tree, blob, tag). */
typedef struct typedef struct {
{
/** raw binary formatted id */ /** raw binary formatted id */
unsigned char id[GIT_OID_RAWSZ]; unsigned char id[GIT_OID_RAWSZ];
} git_oid; } git_oid;
......
...@@ -25,7 +25,7 @@ GIT_BEGIN_DECL ...@@ -25,7 +25,7 @@ GIT_BEGIN_DECL
* @param db the database objects are read from. * @param db the database objects are read from.
* @return the new traversal handle; NULL if memory is exhausted. * @return the new traversal handle; NULL if memory is exhausted.
*/ */
GIT_EXTERN(git_revpool*) gitrp_alloc(git_odb *db); GIT_EXTERN(git_revpool *) gitrp_alloc(git_odb *db);
/** /**
* Reset the traversal machinary for reuse. * Reset the traversal machinary for reuse.
...@@ -52,7 +52,7 @@ GIT_EXTERN(void) gitrp_hide(git_revpool *pool, git_commit *commit); ...@@ -52,7 +52,7 @@ GIT_EXTERN(void) gitrp_hide(git_revpool *pool, git_commit *commit);
* @param pool the pool to pop the commit from. * @param pool the pool to pop the commit from.
* @return next commit; NULL if there is no more output. * @return next commit; NULL if there is no more output.
*/ */
GIT_EXTERN(git_commit*) gitrp_next(git_revpool *pool); GIT_EXTERN(git_commit *) gitrp_next(git_revpool *pool);
/** /**
* Free a revwalk previously allocated. * Free a revwalk previously allocated.
......
...@@ -100,7 +100,7 @@ typedef struct { /* object header data */ ...@@ -100,7 +100,7 @@ typedef struct { /* object header data */
static struct { static struct {
const char *str; /* type name string */ const char *str; /* type name string */
int loose; /* valid loose object type flag */ int loose; /* valid loose object type flag */
} obj_type_table [] = { } obj_type_table[] = {
{ "", 0 }, /* 0 = GIT_OBJ__EXT1 */ { "", 0 }, /* 0 = GIT_OBJ__EXT1 */
{ "commit", 1 }, /* 1 = GIT_OBJ_COMMIT */ { "commit", 1 }, /* 1 = GIT_OBJ_COMMIT */
{ "tree", 1 }, /* 2 = GIT_OBJ_TREE */ { "tree", 1 }, /* 2 = GIT_OBJ_TREE */
...@@ -113,7 +113,7 @@ static struct { ...@@ -113,7 +113,7 @@ static struct {
GIT_INLINE(uint32_t) decode32(void *b) GIT_INLINE(uint32_t) decode32(void *b)
{ {
return ntohl(*((uint32_t*)b)); return ntohl(*((uint32_t *)b));
} }
GIT_INLINE(uint64_t) decode64(void *b) GIT_INLINE(uint64_t) decode64(void *b)
...@@ -226,7 +226,7 @@ static int is_zlib_compressed_data(unsigned char *data) ...@@ -226,7 +226,7 @@ static int is_zlib_compressed_data(unsigned char *data)
unsigned int w; unsigned int w;
w = ((unsigned int)(data[0]) << 8) + data[1]; w = ((unsigned int)(data[0]) << 8) + data[1];
return data[0] == 0x78 && !(w %31); return data[0] == 0x78 && !(w % 31);
} }
static size_t get_binary_object_header(obj_hdr *hdr, gitfo_buf *obj) static size_t get_binary_object_header(obj_hdr *hdr, gitfo_buf *obj)
...@@ -712,7 +712,7 @@ static int pack_openidx_v1(git_pack *p) ...@@ -712,7 +712,7 @@ static int pack_openidx_v1(git_pack *p)
p->idx_search = idxv1_search; p->idx_search = idxv1_search;
p->im_fanout = im_fanout; p->im_fanout = im_fanout;
p->im_oid = (unsigned char*)(src_fanout + 256); p->im_oid = (unsigned char *)(src_fanout + 256);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
...@@ -744,7 +744,7 @@ static int idxv2_search(off_t *out, git_pack *p, const git_oid *id) ...@@ -744,7 +744,7 @@ static int idxv2_search(off_t *out, git_pack *p, const git_oid *id)
static int pack_openidx_v2(git_pack *p) static int pack_openidx_v2(git_pack *p)
{ {
unsigned char *data = p->idx_map.data; unsigned char *data = p->idx_map.data;
uint32_t *src_fanout = (uint32_t*)(data + 8); uint32_t *src_fanout = (uint32_t *)(data + 8);
uint32_t *im_fanout; uint32_t *im_fanout;
int j; int j;
...@@ -763,8 +763,8 @@ static int pack_openidx_v2(git_pack *p) ...@@ -763,8 +763,8 @@ static int pack_openidx_v2(git_pack *p)
p->idx_search = idxv2_search; p->idx_search = idxv2_search;
p->im_fanout = im_fanout; p->im_fanout = im_fanout;
p->im_oid = (unsigned char*)(src_fanout + 256); p->im_oid = (unsigned char *)(src_fanout + 256);
p->im_crc = (uint32_t*)(p->im_oid + 20 * p->obj_cnt); p->im_crc = (uint32_t *)(p->im_oid + 20 * p->obj_cnt);
p->im_offset32 = p->im_crc + p->obj_cnt; p->im_offset32 = p->im_crc + p->obj_cnt;
p->im_offset64 = p->im_offset32 + p->obj_cnt; p->im_offset64 = p->im_offset32 + p->obj_cnt;
return GIT_SUCCESS; return GIT_SUCCESS;
...@@ -900,7 +900,7 @@ static int scan_one_pack(void *state, char *name) ...@@ -900,7 +900,7 @@ static int scan_one_pack(void *state, char *name)
return 0; return 0;
} }
static git_packlist* scan_packs(git_odb *db) static git_packlist *scan_packs(git_odb *db)
{ {
char pb[GIT_PATH_MAX]; char pb[GIT_PATH_MAX];
struct scanned_pack *state = NULL, *c; struct scanned_pack *state = NULL, *c;
...@@ -974,7 +974,7 @@ static int search_packs(git_pack **p, off_t *offset, git_odb *db, const git_oid ...@@ -974,7 +974,7 @@ static int search_packs(git_pack **p, off_t *offset, git_odb *db, const git_oid
pack_decidx(pack); pack_decidx(pack);
if (!res) { if (!res) {
packlist_dec(db,pl); packlist_dec(db, pl);
if (p) if (p)
*p = pack; *p = pack;
if (offset) if (offset)
...@@ -984,7 +984,7 @@ static int search_packs(git_pack **p, off_t *offset, git_odb *db, const git_oid ...@@ -984,7 +984,7 @@ static int search_packs(git_pack **p, off_t *offset, git_odb *db, const git_oid
} }
packlist_dec(db,pl); packlist_dec(db, pl);
return GIT_ENOTFOUND; return GIT_ENOTFOUND;
} }
......
...@@ -58,6 +58,6 @@ GIT_INLINE(int) git__is_sizet(off_t p) ...@@ -58,6 +58,6 @@ GIT_INLINE(int) git__is_sizet(off_t p)
alloc = alloc_nr(alloc); \ alloc = alloc_nr(alloc); \
x = xrealloc((x), alloc * sizeof(*(x))); \ x = xrealloc((x), alloc * sizeof(*(x))); \
} \ } \
} while(0) } while (0)
#endif /* INCLUDE_util_h__ */ #endif /* INCLUDE_util_h__ */
...@@ -3,19 +3,19 @@ ...@@ -3,19 +3,19 @@
#include <git/odb.h> #include <git/odb.h>
BEGIN_TEST(type_to_string) BEGIN_TEST(type_to_string)
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_BAD),"")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_BAD), ""));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT1),"")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT1), ""));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_COMMIT),"commit")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_COMMIT), "commit"));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_TREE),"tree")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_TREE), "tree"));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_BLOB),"blob")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_BLOB), "blob"));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_TAG),"tag")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_TAG), "tag"));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT2),"")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ__EXT2), ""));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_OFS_DELTA),"OFS_DELTA")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_OFS_DELTA), "OFS_DELTA"));
must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_REF_DELTA),"REF_DELTA")); must_be_true(!strcmp(git_obj_type_to_string(GIT_OBJ_REF_DELTA), "REF_DELTA"));
must_be_true(!strcmp(git_obj_type_to_string(-2),"")); must_be_true(!strcmp(git_obj_type_to_string(-2), ""));
must_be_true(!strcmp(git_obj_type_to_string(8),"")); must_be_true(!strcmp(git_obj_type_to_string(8), ""));
must_be_true(!strcmp(git_obj_type_to_string(1234),"")); must_be_true(!strcmp(git_obj_type_to_string(1234), ""));
END_TEST END_TEST
BEGIN_TEST(string_to_type) BEGIN_TEST(string_to_type)
......
...@@ -37,7 +37,7 @@ BEGIN_TEST(exists_loose_one) ...@@ -37,7 +37,7 @@ BEGIN_TEST(exists_loose_one)
must_be_true(git_odb_exists(db, &id)); must_be_true(git_odb_exists(db, &id));
/* Test for a non-existant object */ /* Test for a non-existant object */
must_pass(git_oid_mkstr(&id2,"8b137891791fe96927ad78e64b0aad7bded08baa")); must_pass(git_oid_mkstr(&id2, "8b137891791fe96927ad78e64b0aad7bded08baa"));
must_be_true(0 == git_odb_exists(db, &id2)); must_be_true(0 == git_odb_exists(db, &id2));
git_odb_close(db); git_odb_close(db);
......
...@@ -352,14 +352,13 @@ static git_obj some_obj = { ...@@ -352,14 +352,13 @@ static git_obj some_obj = {
static int make_odb_dir(void) static int make_odb_dir(void)
{ {
if (gitfo_mkdir(odb_dir, 0755) < 0) { if (gitfo_mkdir(odb_dir, 0755) < 0) {
if (errno == EEXIST) { int err = errno;
fprintf(stderr, "odb directory \"%s\" already exists!\n", odb_dir); fprintf(stderr, "can't make directory \"%s\"", odb_dir);
if (err == EEXIST)
fprintf(stderr, " (already exists)");
fprintf(stderr, "\n");
return -1; return -1;
} }
fprintf(stderr, "can't make odb directory \"%s\"\n", odb_dir);
return -1;
}
return 0; return 0;
} }
...@@ -370,12 +369,12 @@ static int remove_object_files(object_data *d) ...@@ -370,12 +369,12 @@ static int remove_object_files(object_data *d)
return -1; return -1;
} }
if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) { if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir); fprintf(stderr, "can't remove directory \"%s\"\n", d->dir);
return -1; return -1;
} }
if (gitfo_rmdir(odb_dir) < 0) { if (gitfo_rmdir(odb_dir) < 0) {
fprintf(stderr, "can't remove odb directory \"%s\"\n", odb_dir); fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
return -1; return -1;
} }
......
...@@ -43,11 +43,11 @@ int write_object_data(char *file, void *data, size_t len) ...@@ -43,11 +43,11 @@ int write_object_data(char *file, void *data, size_t len)
int write_object_files(const char *odb_dir, object_data *d) int write_object_files(const char *odb_dir, object_data *d)
{ {
if (gitfo_mkdir(odb_dir, 0755) < 0) { if (gitfo_mkdir(odb_dir, 0755) < 0) {
if (errno == EEXIST) { int err = errno;
fprintf(stderr, "odb directory \"%s\" already exists!\n", odb_dir); fprintf(stderr, "can't make directory \"%s\"", odb_dir);
return -1; if (err == EEXIST)
} fprintf(stderr, " (already exists)");
fprintf(stderr, "can't make odb directory \"%s\"\n", odb_dir); fprintf(stderr, "\n");
return -1; return -1;
} }
...@@ -75,7 +75,7 @@ int remove_object_files(const char *odb_dir, object_data *d) ...@@ -75,7 +75,7 @@ int remove_object_files(const char *odb_dir, object_data *d)
} }
if (gitfo_rmdir(odb_dir) < 0) { if (gitfo_rmdir(odb_dir) < 0) {
fprintf(stderr, "can't remove odb directory \"%s\"\n", odb_dir); fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
return -1; return -1;
} }
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
#define GIT__NO_HIDE_MALLOC #define GIT__NO_HIDE_MALLOC
#include "test_lib.h" #include "test_lib.h"
struct test_info struct test_info {
{
struct test_info *next; struct test_info *next;
const char *test_name; const char *test_name;
const char *file_name; const char *file_name;
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
* @param name C symbol to assign to this test's function. * @param name C symbol to assign to this test's function.
*/ */
#define BEGIN_TEST(name) \ #define BEGIN_TEST(name) \
void testfunc__##name (void) \ void testfunc__##name(void) \
{ \ { \
test_begin(#name, __FILE__, __LINE__); \ test_begin(#name, __FILE__, __LINE__); \
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment