Merge pull request #391 from sschuberth/development Warning fixes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
diff --git a/git.git-authors b/git.git-authors
index 086ab3e..026b35f 100644
--- a/git.git-authors
+++ b/git.git-authors
@@ -61,6 +61,7 @@ ok Pierre Habouzit <madcoder@debian.org>
ok Pieter de Bie <pdebie@ai.rug.nl>
ok René Scharfe <rene.scharfe@lsrfire.ath.cx>
ign Robert Shearman <rob@codeweavers.com> (imap-send)
+ok Sebastian Schuberth <sschuberth@gmail.com>
ok Shawn O. Pearce <spearce@spearce.org>
ok Steffen Prohaska <prohaska@zib.de>
ok Sven Verdoolaege <skimo@kotnet.org>
diff --git a/include/git2/blob.h b/include/git2/blob.h
index e366ce8..97739d0 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -106,7 +106,7 @@ GIT_EXTERN(const void *) git_blob_rawcontent(git_blob *blob);
* @param blob pointer to the blob
* @return size on bytes
*/
-GIT_EXTERN(int) git_blob_rawsize(git_blob *blob);
+GIT_EXTERN(size_t) git_blob_rawsize(git_blob *blob);
/**
* Read a file from the working folder of a repository
diff --git a/src/blob.c b/src/blob.c
index b8282e5..0f4fa18 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -36,7 +36,7 @@ const void *git_blob_rawcontent(git_blob *blob)
return blob->odb_object->raw.data;
}
-int git_blob_rawsize(git_blob *blob)
+size_t git_blob_rawsize(git_blob *blob)
{
assert(blob);
return blob->odb_object->raw.len;
diff --git a/src/config_file.c b/src/config_file.c
index 520a806..7fb54a6 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -135,7 +135,7 @@ static int cvar_match_section(const char *local, const char *input)
{
char *first_dot;
char *local_sp = strchr(local, ' ');
- int comparison_len;
+ size_t comparison_len;
/*
* If the local section name doesn't contain a space, then we can
@@ -198,7 +198,8 @@ static int cvar_normalize_name(cvar_t *var, char **output)
{
char *section_sp = strchr(var->section, ' ');
char *quote, *name;
- int len, ret;
+ size_t len;
+ int ret;
/*
* The final string is going to be at most one char longer than
@@ -245,7 +246,7 @@ static int cvar_normalize_name(cvar_t *var, char **output)
static char *interiorize_section(const char *orig)
{
char *dot, *last_dot, *section, *ret;
- int len;
+ size_t len;
dot = strchr(orig, '.');
last_dot = strrchr(orig, '.');
@@ -530,7 +531,7 @@ static char *cfg_readline(diskfile_backend *cfg)
{
char *line = NULL;
char *line_src, *line_end;
- int line_len;
+ size_t line_len;
line_src = cfg->reader.read_ptr;
@@ -538,9 +539,9 @@ static char *cfg_readline(diskfile_backend *cfg)
while (isspace(*line_src))
++line_src;
- line_end = strchr(line_src, '\n');
+ line_end = strchr(line_src, '\n');
- /* no newline at EOF */
+ /* no newline at EOF */
if (line_end == NULL)
line_end = strchr(line_src, 0);
@@ -600,7 +601,8 @@ GIT_INLINE(int) config_keychar(int c)
static int parse_section_header_ext(const char *line, const char *base_name, char **section_name)
{
- int buf_len, total_len, pos, rpos;
+ size_t buf_len, total_len;
+ int pos, rpos;
int c, ret;
char *subsection, *first_quote, *last_quote;
int error = GIT_SUCCESS;
@@ -1100,7 +1102,8 @@ static int is_multiline_var(const char *str)
static int parse_multiline_variable(diskfile_backend *cfg, const char *first, char **out)
{
char *line = NULL, *end;
- int error = GIT_SUCCESS, len, ret;
+ int error = GIT_SUCCESS, ret;
+ size_t len;
char *buf;
/* Check that the next line exists */
diff --git a/src/filebuf.c b/src/filebuf.c
index 6d398a7..e8c5087 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -116,24 +116,24 @@ static int write_deflate(git_filebuf *file, void *source, size_t len)
z_stream *zs = &file->zs;
if (len > 0 || file->flush_mode == Z_FINISH) {
- zs->next_in = (void *)source;
- zs->avail_in = len;
+ zs->next_in = source;
+ zs->avail_in = (uInt)len;
do {
- int have;
+ size_t have;
zs->next_out = file->z_buf;
- zs->avail_out = file->buf_size;
+ zs->avail_out = (uInt)file->buf_size;
- result = deflate(zs, file->flush_mode);
- assert(result != Z_STREAM_ERROR);
+ result = deflate(zs, file->flush_mode);
+ assert(result != Z_STREAM_ERROR);
- have = file->buf_size - zs->avail_out;
+ have = file->buf_size - (size_t)zs->avail_out;
if (p_write(file->fd, file->z_buf, have) < GIT_SUCCESS)
return git__throw(GIT_EOSERR, "Failed to write to file");
- } while (zs->avail_out == 0);
+ } while (zs->avail_out == 0);
assert(zs->avail_in == 0);
diff --git a/src/indexer.c b/src/indexer.c
index 3934250..eb7d9d4 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -99,7 +99,7 @@ static int cache_cmp(const void *a, const void *b)
int git_indexer_new(git_indexer **out, const char *packname)
{
git_indexer *idx;
- unsigned int namelen;
+ size_t namelen;
int ret, error;
assert(out && packname);
@@ -186,7 +186,8 @@ static void index_path(char *path, git_indexer *idx)
int git_indexer_write(git_indexer *idx)
{
git_mwindow *w = NULL;
- int error, namelen;
+ int error;
+ size_t namelen;
unsigned int i, long_offsets = 0, left;
struct git_pack_idx_header hdr;
char filename[GIT_PATH_MAX];
diff --git a/src/mwindow.c b/src/mwindow.c
index 585d75c..b259218 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -35,7 +35,7 @@
: 32 * 1024 * 1024)
#define DEFAULT_MAPPED_LIMIT \
- ((1024L * 1024L) * (sizeof(void*) >= 8 ? 8192 : 256))
+ ((1024 * 1024) * (sizeof(void*) >= 8 ? 8192ULL : 256UL))
/*
* We need this because each process is only allowed a specific amount
diff --git a/src/odb_loose.c b/src/odb_loose.c
index a3a4e5b..e6aecc6 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -183,19 +183,19 @@ static void init_stream(z_stream *s, void *out, size_t len)
{
memset(s, 0, sizeof(*s));
s->next_out = out;
- s->avail_out = len;
+ s->avail_out = (uInt)len;
}
static void set_stream_input(z_stream *s, void *in, size_t len)
{
s->next_in = in;
- s->avail_in = len;
+ s->avail_in = (uInt)len;
}
static void set_stream_output(z_stream *s, void *out, size_t len)
{
s->next_out = out;
- s->avail_out = len;
+ s->avail_out = (uInt)len;
}
@@ -243,10 +243,10 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen)
memset(&zs, 0x0, sizeof(zs));
zs.next_out = out;
- zs.avail_out = outlen;
+ zs.avail_out = (uInt)outlen;
zs.next_in = in;
- zs.avail_in = inlen;
+ zs.avail_in = (uInt)inlen;
if (inflateInit(&zs) < Z_OK)
return git__throw(GIT_ERROR, "Failed to inflate buffer");
diff --git a/src/pack.c b/src/pack.c
index d882516..d5e069a 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -404,7 +404,7 @@ int packfile_unpack_compressed(
memset(&stream, 0, sizeof(stream));
stream.next_out = buffer;
- stream.avail_out = size + 1;
+ stream.avail_out = (uInt)size + 1;
st = inflateInit(&stream);
if (st != Z_OK) {
diff --git a/src/util.c b/src/util.c
index 29bf755..a171f65 100644
--- a/src/util.c
+++ b/src/util.c
@@ -118,9 +118,9 @@ Return:
return GIT_SUCCESS;
}
-void git__strntolower(char *str, int len)
+void git__strntolower(char *str, size_t len)
{
- int i;
+ size_t i;
for (i = 0; i < len; ++i) {
str[i] = (char) tolower(str[i]);
diff --git a/src/util.h b/src/util.h
index 78f9f82..2b00979 100644
--- a/src/util.h
+++ b/src/util.h
@@ -90,7 +90,7 @@ GIT_INLINE(int) git__is_sizet(git_off_t p)
extern char *git__strtok(char **end, const char *sep);
-extern void git__strntolower(char *str, int len);
+extern void git__strntolower(char *str, size_t len);
extern void git__strtolower(char *str);
extern int git__fnmatch(const char *pattern, const char *name, int flags);