Commit a44fc1d4 by Vicent Marti

Fix type-conversion warnings

The types in the git_index_entry struct are now system-defaults, and get
truncated to uint32_t's when written back on the index.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
parent f5918330
...@@ -45,8 +45,8 @@ GIT_BEGIN_DECL ...@@ -45,8 +45,8 @@ GIT_BEGIN_DECL
/** Time used in a git index entry */ /** Time used in a git index entry */
typedef struct { typedef struct {
unsigned int seconds; time_t seconds;
unsigned int nanoseconds; time_t nanoseconds;
} git_index_time; } git_index_time;
/** Memory representation of a file entry in the index. */ /** Memory representation of a file entry in the index. */
...@@ -59,7 +59,7 @@ typedef struct git_index_entry { ...@@ -59,7 +59,7 @@ typedef struct git_index_entry {
unsigned int mode; unsigned int mode;
unsigned int uid; unsigned int uid;
unsigned int gid; unsigned int gid;
unsigned int file_size; off_t file_size;
git_oid oid; git_oid oid;
......
...@@ -61,9 +61,14 @@ struct index_extension { ...@@ -61,9 +61,14 @@ struct index_extension {
uint32_t extension_size; uint32_t extension_size;
}; };
struct entry_time {
uint32_t seconds;
uint32_t nanoseconds;
};
struct entry_short { struct entry_short {
git_index_time ctime; struct entry_time ctime;
git_index_time mtime; struct entry_time mtime;
uint32_t dev; uint32_t dev;
uint32_t ino; uint32_t ino;
uint32_t mode; uint32_t mode;
...@@ -76,8 +81,8 @@ struct entry_short { ...@@ -76,8 +81,8 @@ struct entry_short {
}; };
struct entry_long { struct entry_long {
git_index_time ctime; struct entry_time ctime;
git_index_time mtime; struct entry_time mtime;
uint32_t dev; uint32_t dev;
uint32_t ino; uint32_t ino;
uint32_t mode; uint32_t mode;
...@@ -497,10 +502,10 @@ static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffe ...@@ -497,10 +502,10 @@ static size_t read_entry(git_index_entry *dest, const void *buffer, size_t buffe
source = (const struct entry_short *)(buffer); source = (const struct entry_short *)(buffer);
dest->ctime.seconds = ntohl(source->ctime.seconds); dest->ctime.seconds = (time_t)ntohl(source->ctime.seconds);
dest->ctime.nanoseconds = ntohl(source->ctime.nanoseconds); dest->ctime.nanoseconds = (time_t)ntohl(source->ctime.nanoseconds);
dest->mtime.seconds = ntohl(source->mtime.seconds); dest->mtime.seconds = (time_t)ntohl(source->mtime.seconds);
dest->mtime.nanoseconds = ntohl(source->mtime.nanoseconds); dest->mtime.nanoseconds = (time_t)ntohl(source->mtime.nanoseconds);
dest->dev = ntohl(source->dev); dest->dev = ntohl(source->dev);
dest->ino = ntohl(source->ino); dest->ino = ntohl(source->ino);
dest->mode = ntohl(source->mode); dest->mode = ntohl(source->mode);
...@@ -692,7 +697,7 @@ int git_index__write(git_index *index, git_filelock *file) ...@@ -692,7 +697,7 @@ int git_index__write(git_index *index, git_filelock *file)
return GIT_ENOMEM; return GIT_ENOMEM;
#define WRITE_WORD(_word) {\ #define WRITE_WORD(_word) {\
uint32_t network_word = htonl((_word));\ uint32_t network_word = htonl(((uint32_t)(_word)));\
git_filelock_write(file, &network_word, 4);\ git_filelock_write(file, &network_word, 4);\
git_hash_update(digest, &network_word, 4);\ git_hash_update(digest, &network_word, 4);\
} }
......
...@@ -34,7 +34,7 @@ static int resize_vector(git_vector *v) ...@@ -34,7 +34,7 @@ static int resize_vector(git_vector *v)
{ {
void **new_contents; void **new_contents;
v->_alloc_size *= resize_factor; v->_alloc_size = (unsigned int)(v->_alloc_size * resize_factor);
if (v->_alloc_size == 0) if (v->_alloc_size == 0)
v->_alloc_size = minimum_size; v->_alloc_size = minimum_size;
......
...@@ -15,7 +15,7 @@ struct test_entry { ...@@ -15,7 +15,7 @@ struct test_entry {
unsigned int index; unsigned int index;
char path[128]; char path[128];
size_t file_size; size_t file_size;
uint32_t mtime; time_t mtime;
}; };
struct test_entry TEST_ENTRIES[] = { struct test_entry TEST_ENTRIES[] = {
......
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