Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
3f035860
Commit
3f035860
authored
Jun 07, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc: Fix warnings from PVS Studio trial
parent
763b8381
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
26 additions
and
20 deletions
+26
-20
include/git2/diff.h
+1
-1
src/attr.c
+1
-1
src/buffer.c
+2
-1
src/cache.c
+1
-1
src/date.c
+1
-1
src/diff_output.c
+1
-1
src/indexer.c
+3
-1
src/notes.c
+2
-2
src/remote.c
+5
-2
src/revparse.c
+1
-1
src/tree-cache.c
+1
-1
src/tree.c
+1
-1
src/win32/posix_w32.c
+1
-1
tests-clar/core/filebuf.c
+2
-2
tests-clar/index/tests.c
+1
-1
tests-clar/object/tree/write.c
+2
-2
No files found.
include/git2/diff.h
View file @
3f035860
...
@@ -96,9 +96,9 @@ typedef enum {
...
@@ -96,9 +96,9 @@ typedef enum {
typedef
struct
{
typedef
struct
{
git_oid
oid
;
git_oid
oid
;
char
*
path
;
char
*
path
;
uint16_t
mode
;
git_off_t
size
;
git_off_t
size
;
unsigned
int
flags
;
unsigned
int
flags
;
uint16_t
mode
;
}
git_diff_file
;
}
git_diff_file
;
/**
/**
...
...
src/attr.c
View file @
3f035860
...
@@ -415,7 +415,7 @@ int git_attr_cache__push_file(
...
@@ -415,7 +415,7 @@ int git_attr_cache__push_file(
if
(
parse
&&
(
error
=
parse
(
repo
,
content
,
file
))
<
0
)
if
(
parse
&&
(
error
=
parse
(
repo
,
content
,
file
))
<
0
)
goto
finish
;
goto
finish
;
git_strmap_insert
(
cache
->
files
,
file
->
key
,
file
,
error
);
git_strmap_insert
(
cache
->
files
,
file
->
key
,
file
,
error
);
//-V595
if
(
error
>
0
)
if
(
error
>
0
)
error
=
0
;
error
=
0
;
...
...
src/buffer.c
View file @
3f035860
...
@@ -144,8 +144,9 @@ int git_buf_puts(git_buf *buf, const char *string)
...
@@ -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
git_buf_vprintf
(
git_buf
*
buf
,
const
char
*
format
,
va_list
ap
)
{
{
int
len
;
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
)
{
while
(
1
)
{
va_list
args
;
va_list
args
;
...
...
src/cache.c
View file @
3f035860
...
@@ -69,7 +69,7 @@ void *git_cache_try_store(git_cache *cache, void *_entry)
...
@@ -69,7 +69,7 @@ void *git_cache_try_store(git_cache *cache, void *_entry)
git_cached_obj
*
entry
=
_entry
;
git_cached_obj
*
entry
=
_entry
;
uint32_t
hash
;
uint32_t
hash
;
memcpy
(
&
hash
,
&
entry
->
oid
,
sizeof
(
hash
));
memcpy
(
&
hash
,
&
entry
->
oid
,
sizeof
(
uint32_t
));
/* increase the refcount on this object, because
/* increase the refcount on this object, because
* the cache now owns it */
* the cache now owns it */
...
...
src/date.c
View file @
3f035860
...
@@ -531,7 +531,7 @@ static int parse_date_basic(const char *date, git_time_t *timestamp, int *offset
...
@@ -531,7 +531,7 @@ static int parse_date_basic(const char *date, git_time_t *timestamp, int *offset
/* mktime uses local timezone */
/* mktime uses local timezone */
*
timestamp
=
tm_to_time_t
(
&
tm
);
*
timestamp
=
tm_to_time_t
(
&
tm
);
if
(
*
offset
==
-
1
)
if
(
*
offset
==
-
1
)
*
offset
=
((
time_t
)
*
timestamp
-
mktime
(
&
tm
))
/
60
;
*
offset
=
(
int
)(
(
time_t
)
*
timestamp
-
mktime
(
&
tm
))
/
60
;
if
(
*
timestamp
==
(
git_time_t
)
-
1
)
if
(
*
timestamp
==
(
git_time_t
)
-
1
)
return
-
1
;
return
-
1
;
...
...
src/diff_output.c
View file @
3f035860
...
@@ -467,7 +467,7 @@ static char pick_suffix(int mode)
...
@@ -467,7 +467,7 @@ static char pick_suffix(int mode)
{
{
if
(
S_ISDIR
(
mode
))
if
(
S_ISDIR
(
mode
))
return
'/'
;
return
'/'
;
else
if
(
mode
&
0100
)
else
if
(
mode
&
0100
)
//-V536
/* in git, modes are very regular, so we must have 0100755 mode */
/* in git, modes are very regular, so we must have 0100755 mode */
return
'*'
;
return
'*'
;
else
else
...
...
src/indexer.c
View file @
3f035860
...
@@ -292,11 +292,13 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
...
@@ -292,11 +292,13 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
{
{
int
error
;
int
error
;
struct
git_pack_header
hdr
;
struct
git_pack_header
hdr
;
size_t
processed
=
stats
->
processed
;
size_t
processed
;
git_mwindow_file
*
mwf
=
&
idx
->
pack
->
mwf
;
git_mwindow_file
*
mwf
=
&
idx
->
pack
->
mwf
;
assert
(
idx
&&
data
&&
stats
);
assert
(
idx
&&
data
&&
stats
);
processed
=
stats
->
processed
;
if
(
git_filebuf_write
(
&
idx
->
pack_file
,
data
,
size
)
<
0
)
if
(
git_filebuf_write
(
&
idx
->
pack_file
,
data
,
size
)
<
0
)
return
-
1
;
return
-
1
;
...
...
src/notes.c
View file @
3f035860
...
@@ -125,7 +125,7 @@ static int note_write(git_oid *out, git_repository *repo,
...
@@ -125,7 +125,7 @@ static int note_write(git_oid *out, git_repository *repo,
return
error
;
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
)
{
if
(
error
<
0
)
{
/* libgit2 doesn't support object removal (gc) yet */
/* libgit2 doesn't support object removal (gc) yet */
/* we leave an orphaned blob object behind - TODO */
/* we leave an orphaned blob object behind - TODO */
...
@@ -154,7 +154,7 @@ static int note_write(git_oid *out, git_repository *repo,
...
@@ -154,7 +154,7 @@ static int note_write(git_oid *out, git_repository *repo,
if
(
error
<
0
)
if
(
error
<
0
)
return
error
;
return
error
;
error
=
git_treebuilder_insert
(
NULL
,
tb
,
subtree
,
&
oid
,
0040000
);
error
=
git_treebuilder_insert
(
NULL
,
tb
,
subtree
,
&
oid
,
0040000
);
//-V536
if
(
error
<
0
)
{
if
(
error
<
0
)
{
git_treebuilder_free
(
tb
);
git_treebuilder_free
(
tb
);
return
error
;
return
error
;
...
...
src/remote.c
View file @
3f035860
...
@@ -337,13 +337,16 @@ int git_remote_update_tips(git_remote *remote, int (*cb)(const char *refname, co
...
@@ -337,13 +337,16 @@ int git_remote_update_tips(git_remote *remote, int (*cb)(const char *refname, co
unsigned
int
i
=
0
;
unsigned
int
i
=
0
;
git_buf
refname
=
GIT_BUF_INIT
;
git_buf
refname
=
GIT_BUF_INIT
;
git_oid
old
;
git_oid
old
;
git_vector
*
refs
=
&
remote
->
refs
;
git_vector
*
refs
;
git_remote_head
*
head
;
git_remote_head
*
head
;
git_reference
*
ref
;
git_reference
*
ref
;
struct
git_refspec
*
spec
=
&
remote
->
fetch
;
struct
git_refspec
*
spec
;
assert
(
remote
);
assert
(
remote
);
refs
=
&
remote
->
refs
;
spec
=
&
remote
->
fetch
;
if
(
refs
->
length
==
0
)
if
(
refs
->
length
==
0
)
return
0
;
return
0
;
...
...
src/revparse.c
View file @
3f035860
...
@@ -506,7 +506,7 @@ static int handle_linear_syntax(git_object **out, git_object *obj, const char *m
...
@@ -506,7 +506,7 @@ static int handle_linear_syntax(git_object **out, git_object *obj, const char *m
}
}
/* "~" is the same as "~1" */
/* "~" is the same as "~1" */
if
(
strlen
(
movement
)
==
0
)
{
if
(
*
movement
==
'\0'
)
{
n
=
1
;
n
=
1
;
}
else
{
}
else
{
git__strtol32
(
&
n
,
movement
,
NULL
,
0
);
git__strtol32
(
&
n
,
movement
,
NULL
,
0
);
...
...
src/tree-cache.c
View file @
3f035860
...
@@ -69,7 +69,7 @@ const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char
...
@@ -69,7 +69,7 @@ const git_tree_cache *git_tree_cache_get(const git_tree_cache *tree, const char
return
NULL
;
return
NULL
;
}
}
if
(
end
==
NULL
||
end
+
1
==
'\0'
)
if
(
end
==
NULL
||
*
end
+
1
==
'\0'
)
return
tree
;
return
tree
;
ptr
=
end
+
1
;
ptr
=
end
+
1
;
...
...
src/tree.c
View file @
3f035860
...
@@ -22,7 +22,7 @@ static int valid_attributes(const int attributes)
...
@@ -22,7 +22,7 @@ static int valid_attributes(const int attributes)
static
int
valid_entry_name
(
const
char
*
filename
)
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
)
static
int
entry_sort_cmp
(
const
void
*
a
,
const
void
*
b
)
...
...
src/win32/posix_w32.c
View file @
3f035860
...
@@ -414,7 +414,7 @@ int p_mkstemp(char *tmp_path)
...
@@ -414,7 +414,7 @@ int p_mkstemp(char *tmp_path)
return
-
1
;
return
-
1
;
#endif
#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
)
int
p_setenv
(
const
char
*
name
,
const
char
*
value
,
int
overwrite
)
...
...
tests-clar/core/filebuf.c
View file @
3f035860
...
@@ -8,7 +8,7 @@ void test_core_filebuf__0(void)
...
@@ -8,7 +8,7 @@ void test_core_filebuf__0(void)
int
fd
;
int
fd
;
char
test
[]
=
"test"
,
testlock
[]
=
"test.lock"
;
char
test
[]
=
"test"
,
testlock
[]
=
"test.lock"
;
fd
=
p_creat
(
testlock
,
0744
);
fd
=
p_creat
(
testlock
,
0744
);
//-V536
cl_must_pass
(
fd
);
cl_must_pass
(
fd
);
cl_must_pass
(
p_close
(
fd
));
cl_must_pass
(
p_close
(
fd
));
...
@@ -27,7 +27,7 @@ void test_core_filebuf__1(void)
...
@@ -27,7 +27,7 @@ void test_core_filebuf__1(void)
int
fd
;
int
fd
;
char
test
[]
=
"test"
;
char
test
[]
=
"test"
;
fd
=
p_creat
(
test
,
0666
);
fd
=
p_creat
(
test
,
0666
);
//-V536
cl_must_pass
(
fd
);
cl_must_pass
(
fd
);
cl_must_pass
(
p_write
(
fd
,
"libgit2 rocks
\n
"
,
14
));
cl_must_pass
(
p_write
(
fd
,
"libgit2 rocks
\n
"
,
14
));
cl_must_pass
(
p_close
(
fd
));
cl_must_pass
(
p_close
(
fd
));
...
...
tests-clar/index/tests.c
View file @
3f035860
...
@@ -33,7 +33,7 @@ static void copy_file(const char *src, const char *dst)
...
@@ -33,7 +33,7 @@ static void copy_file(const char *src, const char *dst)
cl_git_pass
(
git_futils_readbuffer
(
&
source_buf
,
src
));
cl_git_pass
(
git_futils_readbuffer
(
&
source_buf
,
src
));
dst_fd
=
git_futils_creat_withpath
(
dst
,
0777
,
0666
);
dst_fd
=
git_futils_creat_withpath
(
dst
,
0777
,
0666
);
//-V536
if
(
dst_fd
<
0
)
if
(
dst_fd
<
0
)
goto
cleanup
;
goto
cleanup
;
...
...
tests-clar/object/tree/write.c
View file @
3f035860
...
@@ -63,14 +63,14 @@ void test_object_tree_write__subtree(void)
...
@@ -63,14 +63,14 @@ void test_object_tree_write__subtree(void)
//create subtree
//create subtree
cl_git_pass
(
git_treebuilder_create
(
&
builder
,
NULL
));
cl_git_pass
(
git_treebuilder_create
(
&
builder
,
NULL
));
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new.txt"
,
&
bid
,
0100644
));
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new.txt"
,
&
bid
,
0100644
));
//-V536
cl_git_pass
(
git_treebuilder_write
(
&
subtree_id
,
g_repo
,
builder
));
cl_git_pass
(
git_treebuilder_write
(
&
subtree_id
,
g_repo
,
builder
));
git_treebuilder_free
(
builder
);
git_treebuilder_free
(
builder
);
// create parent tree
// create parent tree
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
id
));
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
id
));
cl_git_pass
(
git_treebuilder_create
(
&
builder
,
tree
));
cl_git_pass
(
git_treebuilder_create
(
&
builder
,
tree
));
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new"
,
&
subtree_id
,
040000
));
cl_git_pass
(
git_treebuilder_insert
(
NULL
,
builder
,
"new"
,
&
subtree_id
,
040000
));
//-V536
cl_git_pass
(
git_treebuilder_write
(
&
id_hiearar
,
g_repo
,
builder
));
cl_git_pass
(
git_treebuilder_write
(
&
id_hiearar
,
g_repo
,
builder
));
git_treebuilder_free
(
builder
);
git_treebuilder_free
(
builder
);
git_tree_free
(
tree
);
git_tree_free
(
tree
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment