summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Martí <tanoku@gmail.com>2012-06-07 22:43:03 +0200
committerVicent Martí <tanoku@gmail.com>2012-06-07 22:43:48 +0200
commit3f0358604e48432b53abf097aa3ab6a1e3639813 (patch)
treec132a79507bb39fc37abb49e361f2f720bc69737 /src
parent763b838152244c0d7433cde0046e9f67369074e3 (diff)
downloadlibgit2-3f0358604e48432b53abf097aa3ab6a1e3639813.tar.gz
misc: Fix warnings from PVS Studio trial
Diffstat (limited to 'src')
-rw-r--r--src/attr.c2
-rw-r--r--src/buffer.c3
-rw-r--r--src/cache.c2
-rw-r--r--src/date.c2
-rw-r--r--src/diff_output.c2
-rw-r--r--src/indexer.c4
-rw-r--r--src/notes.c4
-rw-r--r--src/remote.c7
-rw-r--r--src/revparse.c2
-rw-r--r--src/tree-cache.c2
-rw-r--r--src/tree.c2
-rw-r--r--src/win32/posix_w32.c2
12 files changed, 20 insertions, 14 deletions
diff --git a/src/attr.c b/src/attr.c
index fb6651196..6fbd005d5 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -415,7 +415,7 @@ int git_attr_cache__push_file(
if (parse && (error = parse(repo, content, file)) < 0)
goto finish;
- git_strmap_insert(cache->files, file->key, file, error);
+ git_strmap_insert(cache->files, file->key, file, error); //-V595
if (error > 0)
error = 0;
diff --git a/src/buffer.c b/src/buffer.c
index 783a36eb8..04aaec3df 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -144,8 +144,9 @@ int git_buf_puts(git_buf *buf, const char *string)
int git_buf_vprintf(git_buf *buf, const char *format, va_list ap)
{
int len;
+ const size_t expected_size = buf->size + (strlen(format) * 2);
- ENSURE_SIZE(buf, buf->size + (strlen(format) * 2));
+ ENSURE_SIZE(buf, expected_size);
while (1) {
va_list args;
diff --git a/src/cache.c b/src/cache.c
index 31da3c36e..f8d89403b 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -69,7 +69,7 @@ void *git_cache_try_store(git_cache *cache, void *_entry)
git_cached_obj *entry = _entry;
uint32_t hash;
- memcpy(&hash, &entry->oid, sizeof(hash));
+ memcpy(&hash, &entry->oid, sizeof(uint32_t));
/* increase the refcount on this object, because
* the cache now owns it */
diff --git a/src/date.c b/src/date.c
index 658b09eb5..f0e637a45 100644
--- a/src/date.c
+++ b/src/date.c
@@ -531,7 +531,7 @@ static int parse_date_basic(const char *date, git_time_t *timestamp, int *offset
/* mktime uses local timezone */
*timestamp = tm_to_time_t(&tm);
if (*offset == -1)
- *offset = ((time_t)*timestamp - mktime(&tm)) / 60;
+ *offset = (int)((time_t)*timestamp - mktime(&tm)) / 60;
if (*timestamp == (git_time_t)-1)
return -1;
diff --git a/src/diff_output.c b/src/diff_output.c
index 5ffa641c4..1c65e1bb8 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -467,7 +467,7 @@ static char pick_suffix(int mode)
{
if (S_ISDIR(mode))
return '/';
- else if (mode & 0100)
+ else if (mode & 0100) //-V536
/* in git, modes are very regular, so we must have 0100755 mode */
return '*';
else
diff --git a/src/indexer.c b/src/indexer.c
index f0e0a6381..5ae66c9f1 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -292,11 +292,13 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
{
int error;
struct git_pack_header hdr;
- size_t processed = stats->processed;
+ size_t processed;
git_mwindow_file *mwf = &idx->pack->mwf;
assert(idx && data && stats);
+ processed = stats->processed;
+
if (git_filebuf_write(&idx->pack_file, data, size) < 0)
return -1;
diff --git a/src/notes.c b/src/notes.c
index 84ad94087..e87ea65fb 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -125,7 +125,7 @@ static int note_write(git_oid *out, git_repository *repo,
return error;
}
- error = git_treebuilder_insert(&entry, tb, target + fanout, &oid, 0100644);
+ error = git_treebuilder_insert(&entry, tb, target + fanout, &oid, 0100644); //-V536
if (error < 0) {
/* libgit2 doesn't support object removal (gc) yet */
/* we leave an orphaned blob object behind - TODO */
@@ -154,7 +154,7 @@ static int note_write(git_oid *out, git_repository *repo,
if (error < 0)
return error;
- error = git_treebuilder_insert(NULL, tb, subtree, &oid, 0040000);
+ error = git_treebuilder_insert(NULL, tb, subtree, &oid, 0040000); //-V536
if (error < 0) {
git_treebuilder_free(tb);
return error;
diff --git a/src/remote.c b/src/remote.c
index 8d6076107..00e108a0a 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -337,13 +337,16 @@ int git_remote_update_tips(git_remote *remote, int (*cb)(const char *refname, co
unsigned int i = 0;
git_buf refname = GIT_BUF_INIT;
git_oid old;
- git_vector *refs = &remote->refs;
+ git_vector *refs;
git_remote_head *head;
git_reference *ref;
- struct git_refspec *spec = &remote->fetch;
+ struct git_refspec *spec;
assert(remote);
+ refs = &remote->refs;
+ spec = &remote->fetch;
+
if (refs->length == 0)
return 0;
diff --git a/src/revparse.c b/src/revparse.c
index dd8476e35..1e6b7101f 100644
--- a/src/revparse.c
+++ b/src/revparse.c
@@ -506,7 +506,7 @@ static int handle_linear_syntax(git_object **out, git_object *obj, const char *m
}
/* "~" is the same as "~1" */
- if (strlen(movement) == 0) {
+ if (*movement == '\0') {
n = 1;
} else {
git__strtol32(&n, movement, NULL, 0);
diff --git a/src/tree-cache.c b/src/tree-cache.c
index ebc2c6807..8d186d2fb 100644
--- a/src/tree-cache.c
+++ b/src/tree-cache.c
@@ -69,7 +69,7 @@ const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char
return NULL;
}
- if (end == NULL || end + 1 == '\0')
+ if (end == NULL || *end + 1 == '\0')
return tree;
ptr = end + 1;
diff --git a/src/tree.c b/src/tree.c
index 92b1b1e39..d575dc8ff 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -22,7 +22,7 @@ static int valid_attributes(const int attributes)
static int valid_entry_name(const char *filename)
{
- return strlen(filename) > 0 && strchr(filename, '/') == NULL;
+ return *filename != '\0' && strchr(filename, '/') == NULL;
}
static int entry_sort_cmp(const void *a, const void *b)
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index f0441df97..37956af85 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -414,7 +414,7 @@ int p_mkstemp(char *tmp_path)
return -1;
#endif
- return p_creat(tmp_path, 0744);
+ return p_creat(tmp_path, 0744); //-V536
}
int p_setenv(const char* name, const char* value, int overwrite)