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
50eb8520
Commit
50eb8520
authored
Mar 18, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1420 from KindDragon/static-code-analyzer-warnings
Several warnings detected by static code analyzer fixed
parents
677dce8a
10c06114
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
62 additions
and
48 deletions
+62
-48
deps/regex/regex_internal.c
+1
-1
src/branch.c
+1
-1
src/commit.c
+1
-1
src/config.c
+3
-3
src/diff_output.c
+1
-1
src/fileops.c
+1
-1
src/filter.c
+2
-1
src/index.c
+3
-3
src/indexer.c
+9
-3
src/mwindow.c
+3
-3
src/odb.c
+10
-10
src/odb_pack.c
+4
-4
src/refdb_fs.c
+2
-2
src/reflog.c
+1
-1
src/refs.c
+12
-5
src/remote.c
+1
-1
src/revparse.c
+3
-3
src/submodule.c
+1
-1
src/transports/local.c
+1
-1
src/transports/smart.c
+1
-1
src/transports/smart_protocol.c
+1
-1
No files found.
deps/regex/regex_internal.c
View file @
50eb8520
...
...
@@ -32,7 +32,7 @@ static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa,
#ifdef GAWK
#undef MAX
/* safety */
static
in
t
static
size_
t
MAX
(
size_t
a
,
size_t
b
)
{
return
(
a
>
b
?
a
:
b
);
...
...
src/branch.c
View file @
50eb8520
...
...
@@ -176,7 +176,7 @@ int git_branch_move(
return
not_a_local_branch
(
git_reference_name
(
branch
));
if
((
error
=
git_buf_joinpath
(
&
new_reference_name
,
GIT_REFS_HEADS_DIR
,
new_branch_name
))
<
0
||
(
error
=
git_buf_printf
(
&
old_config_section
,
"branch.%s"
,
git_reference_name
(
branch
)
+
strlen
(
GIT_REFS_HEADS_DIR
))
<
0
)
||
(
error
=
git_buf_printf
(
&
old_config_section
,
"branch.%s"
,
git_reference_name
(
branch
)
+
strlen
(
GIT_REFS_HEADS_DIR
))
)
<
0
||
(
error
=
git_buf_printf
(
&
new_config_section
,
"branch.%s"
,
new_branch_name
))
<
0
)
goto
done
;
...
...
src/commit.c
View file @
50eb8520
...
...
@@ -20,7 +20,7 @@
static
void
clear_parents
(
git_commit
*
commit
)
{
unsigned
in
t
i
;
size_
t
i
;
for
(
i
=
0
;
i
<
commit
->
parent_ids
.
length
;
++
i
)
{
git_oid
*
parent
=
git_vector_get
(
&
commit
->
parent_ids
,
i
);
...
...
src/config.c
View file @
50eb8520
...
...
@@ -36,7 +36,7 @@ static void file_internal_free(file_internal *internal)
static
void
config_free
(
git_config
*
cfg
)
{
unsigned
in
t
i
;
size_
t
i
;
file_internal
*
internal
;
for
(
i
=
0
;
i
<
cfg
->
files
.
length
;
++
i
){
...
...
@@ -284,7 +284,7 @@ int git_config_add_backend(
int
git_config_refresh
(
git_config
*
cfg
)
{
int
error
=
0
;
unsigned
in
t
i
;
size_
t
i
;
for
(
i
=
0
;
i
<
cfg
->
files
.
length
&&
!
error
;
++
i
)
{
file_internal
*
internal
=
git_vector_get
(
&
cfg
->
files
,
i
);
...
...
@@ -312,7 +312,7 @@ int git_config_foreach_match(
void
*
payload
)
{
int
ret
=
0
;
unsigned
in
t
i
;
size_
t
i
;
file_internal
*
internal
;
git_config_backend
*
file
;
...
...
src/diff_output.c
View file @
50eb8520
...
...
@@ -390,7 +390,7 @@ static int get_workdir_content(
map
->
data
=
git__malloc
(
alloc_len
);
GITERR_CHECK_ALLOC
(
map
->
data
);
read_len
=
p_readlink
(
path
.
ptr
,
map
->
data
,
(
int
)
alloc_len
);
read_len
=
p_readlink
(
path
.
ptr
,
map
->
data
,
alloc_len
);
if
(
read_len
<
0
)
{
giterr_set
(
GITERR_OS
,
"Failed to read symlink '%s'"
,
file
->
path
);
error
=
-
1
;
...
...
src/fileops.c
View file @
50eb8520
...
...
@@ -529,7 +529,7 @@ int git_futils_cleanupdir_r(const char *path)
git_buf
fullpath
=
GIT_BUF_INIT
;
futils__rmdir_data
data
;
if
((
error
=
git_buf_put
(
&
fullpath
,
path
,
strlen
(
path
))
<
0
)
)
if
((
error
=
git_buf_put
(
&
fullpath
,
path
,
strlen
(
path
))
)
<
0
)
goto
clean_up
;
data
.
base
=
""
;
...
...
src/filter.c
View file @
50eb8520
...
...
@@ -48,7 +48,8 @@ void git_filters_free(git_vector *filters)
int
git_filters_apply
(
git_buf
*
dest
,
git_buf
*
source
,
git_vector
*
filters
)
{
unsigned
int
i
,
src
;
size_t
i
;
unsigned
int
src
;
git_buf
*
dbuffer
[
2
];
dbuffer
[
0
]
=
source
;
...
...
src/index.c
View file @
50eb8520
...
...
@@ -317,7 +317,7 @@ void git_index_free(git_index *index)
void
git_index_clear
(
git_index
*
index
)
{
unsigned
in
t
i
;
size_
t
i
;
assert
(
index
);
...
...
@@ -786,7 +786,7 @@ int git_index_remove(git_index *index, const char *path, int stage)
if
(
entry
!=
NULL
)
git_tree_cache_invalidate_path
(
index
->
tree
,
entry
->
path
);
error
=
git_vector_remove
(
&
index
->
entries
,
(
unsigned
int
)
position
);
error
=
git_vector_remove
(
&
index
->
entries
,
position
);
if
(
!
error
)
index_entry_free
(
entry
);
...
...
@@ -1129,7 +1129,7 @@ int git_index_reuc_remove(git_index *index, size_t position)
git_vector_sort
(
&
index
->
reuc
);
reuc
=
git_vector_get
(
&
index
->
reuc
,
position
);
error
=
git_vector_remove
(
&
index
->
reuc
,
(
unsigned
int
)
position
);
error
=
git_vector_remove
(
&
index
->
reuc
,
position
);
if
(
!
error
)
index_entry_reuc_free
(
reuc
);
...
...
src/indexer.c
View file @
50eb8520
...
...
@@ -415,6 +415,8 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
}
if
(
!
idx
->
parsed_header
)
{
unsigned
int
total_objects
;
if
((
unsigned
)
idx
->
pack
->
mwf
.
size
<
sizeof
(
hdr
))
return
0
;
...
...
@@ -427,20 +429,24 @@ int git_indexer_stream_add(git_indexer_stream *idx, const void *data, size_t siz
/* for now, limit to 2^32 objects */
assert
(
idx
->
nr_objects
==
(
size_t
)((
unsigned
int
)
idx
->
nr_objects
));
if
(
idx
->
nr_objects
==
(
size_t
)((
unsigned
int
)
idx
->
nr_objects
))
total_objects
=
(
unsigned
int
)
idx
->
nr_objects
;
else
total_objects
=
UINT_MAX
;
idx
->
pack
->
idx_cache
=
git_oidmap_alloc
();
GITERR_CHECK_ALLOC
(
idx
->
pack
->
idx_cache
);
idx
->
pack
->
has_cache
=
1
;
if
(
git_vector_init
(
&
idx
->
objects
,
(
unsigned
int
)
idx
->
nr
_objects
,
objects_cmp
)
<
0
)
if
(
git_vector_init
(
&
idx
->
objects
,
total
_objects
,
objects_cmp
)
<
0
)
return
-
1
;
if
(
git_vector_init
(
&
idx
->
deltas
,
(
unsigned
int
)(
idx
->
nr_objects
/
2
)
,
NULL
)
<
0
)
if
(
git_vector_init
(
&
idx
->
deltas
,
total_objects
/
2
,
NULL
)
<
0
)
return
-
1
;
stats
->
received_objects
=
0
;
processed
=
stats
->
indexed_objects
=
0
;
stats
->
total_objects
=
(
unsigned
int
)
idx
->
nr
_objects
;
stats
->
total_objects
=
total
_objects
;
do_progress_callback
(
idx
,
stats
);
}
...
...
src/mwindow.c
View file @
50eb8520
...
...
@@ -33,7 +33,7 @@ static git_mwindow_ctl mem_ctl;
void
git_mwindow_free_all
(
git_mwindow_file
*
mwf
)
{
git_mwindow_ctl
*
ctl
=
&
mem_ctl
;
unsigned
in
t
i
;
size_
t
i
;
if
(
git_mutex_lock
(
&
git__mwindow_mutex
))
{
giterr_set
(
GITERR_THREAD
,
"unable to lock mwindow mutex"
);
...
...
@@ -115,7 +115,7 @@ static void git_mwindow_scan_lru(
static
int
git_mwindow_close_lru
(
git_mwindow_file
*
mwf
)
{
git_mwindow_ctl
*
ctl
=
&
mem_ctl
;
unsigned
in
t
i
;
size_
t
i
;
git_mwindow
*
lru_w
=
NULL
,
*
lru_l
=
NULL
,
**
list
=
&
mwf
->
windows
;
/* FIXME: Does this give us any advantage? */
...
...
@@ -288,7 +288,7 @@ void git_mwindow_file_deregister(git_mwindow_file *mwf)
{
git_mwindow_ctl
*
ctl
=
&
mem_ctl
;
git_mwindow_file
*
cur
;
unsigned
in
t
i
;
size_
t
i
;
if
(
git_mutex_lock
(
&
git__mwindow_mutex
))
return
;
...
...
src/odb.c
View file @
50eb8520
...
...
@@ -499,7 +499,7 @@ int git_odb_open(git_odb **out, const char *objects_dir)
static
void
odb_free
(
git_odb
*
db
)
{
unsigned
in
t
i
;
size_
t
i
;
for
(
i
=
0
;
i
<
db
->
backends
.
length
;
++
i
)
{
backend_internal
*
internal
=
git_vector_get
(
&
db
->
backends
,
i
);
...
...
@@ -527,7 +527,7 @@ void git_odb_free(git_odb *db)
int
git_odb_exists
(
git_odb
*
db
,
const
git_oid
*
id
)
{
git_odb_object
*
object
;
unsigned
in
t
i
;
size_
t
i
;
bool
found
=
false
;
bool
refreshed
=
false
;
...
...
@@ -577,7 +577,7 @@ int git_odb__read_header_or_object(
git_odb_object
**
out
,
size_t
*
len_p
,
git_otype
*
type_p
,
git_odb
*
db
,
const
git_oid
*
id
)
{
unsigned
in
t
i
;
size_
t
i
;
int
error
=
GIT_ENOTFOUND
;
git_odb_object
*
object
;
...
...
@@ -619,7 +619,7 @@ int git_odb__read_header_or_object(
int
git_odb_read
(
git_odb_object
**
out
,
git_odb
*
db
,
const
git_oid
*
id
)
{
unsigned
in
t
i
;
size_
t
i
;
int
error
;
bool
refreshed
=
false
;
git_rawobj
raw
;
...
...
@@ -664,7 +664,7 @@ attempt_lookup:
int
git_odb_read_prefix
(
git_odb_object
**
out
,
git_odb
*
db
,
const
git_oid
*
short_id
,
size_t
len
)
{
unsigned
in
t
i
;
size_
t
i
;
int
error
=
GIT_ENOTFOUND
;
git_oid
found_full_oid
=
{{
0
}};
git_rawobj
raw
;
...
...
@@ -743,7 +743,7 @@ int git_odb_foreach(git_odb *db, git_odb_foreach_cb cb, void *payload)
int
git_odb_write
(
git_oid
*
oid
,
git_odb
*
db
,
const
void
*
data
,
size_t
len
,
git_otype
type
)
{
unsigned
in
t
i
;
size_
t
i
;
int
error
=
GIT_ERROR
;
git_odb_stream
*
stream
;
...
...
@@ -785,7 +785,7 @@ int git_odb_write(
int
git_odb_open_wstream
(
git_odb_stream
**
stream
,
git_odb
*
db
,
size_t
size
,
git_otype
type
)
{
unsigned
in
t
i
;
size_
t
i
;
int
error
=
GIT_ERROR
;
assert
(
stream
&&
db
);
...
...
@@ -812,7 +812,7 @@ int git_odb_open_wstream(
int
git_odb_open_rstream
(
git_odb_stream
**
stream
,
git_odb
*
db
,
const
git_oid
*
oid
)
{
unsigned
in
t
i
;
size_
t
i
;
int
error
=
GIT_ERROR
;
assert
(
stream
&&
db
);
...
...
@@ -833,7 +833,7 @@ int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oi
int
git_odb_write_pack
(
struct
git_odb_writepack
**
out
,
git_odb
*
db
,
git_transfer_progress_callback
progress_cb
,
void
*
progress_payload
)
{
unsigned
in
t
i
;
size_
t
i
;
int
error
=
GIT_ERROR
;
assert
(
out
&&
db
);
...
...
@@ -864,7 +864,7 @@ void *git_odb_backend_malloc(git_odb_backend *backend, size_t len)
int
git_odb_refresh
(
struct
git_odb
*
db
)
{
unsigned
in
t
i
;
size_
t
i
;
assert
(
db
);
for
(
i
=
0
;
i
<
db
->
backends
.
length
;
++
i
)
{
...
...
src/odb_pack.c
View file @
50eb8520
...
...
@@ -195,7 +195,7 @@ static int packfile_load__cb(void *_data, git_buf *path)
struct
pack_backend
*
backend
=
(
struct
pack_backend
*
)
_data
;
struct
git_pack_file
*
pack
;
int
error
;
unsigned
in
t
i
;
size_
t
i
;
if
(
git__suffixcmp
(
path
->
ptr
,
".idx"
)
!=
0
)
return
0
;
/* not an index */
...
...
@@ -222,7 +222,7 @@ static int pack_entry_find_inner(
const
git_oid
*
oid
,
struct
git_pack_file
*
last_found
)
{
unsigned
in
t
i
;
size_
t
i
;
if
(
last_found
&&
git_pack_entry_find
(
e
,
last_found
,
oid
,
GIT_OID_HEXSZ
)
==
0
)
...
...
@@ -266,7 +266,7 @@ static unsigned pack_entry_find_prefix_inner(
struct
git_pack_file
*
last_found
)
{
int
error
;
unsigned
in
t
i
;
size_
t
i
;
unsigned
found
=
0
;
if
(
last_found
)
{
...
...
@@ -510,7 +510,7 @@ static int pack_backend__writepack(struct git_odb_writepack **out,
static
void
pack_backend__free
(
git_odb_backend
*
_backend
)
{
struct
pack_backend
*
backend
;
unsigned
in
t
i
;
size_
t
i
;
assert
(
_backend
);
...
...
src/refdb_fs.c
View file @
50eb8520
...
...
@@ -769,7 +769,7 @@ static int packed_remove_loose(
refdb_fs_backend
*
backend
,
git_vector
*
packing_list
)
{
unsigned
in
t
i
;
size_
t
i
;
git_buf
full_path
=
GIT_BUF_INIT
;
int
failed
=
0
;
...
...
@@ -811,7 +811,7 @@ static int packed_remove_loose(
static
int
packed_write
(
refdb_fs_backend
*
backend
)
{
git_filebuf
pack_file
=
GIT_FILEBUF_INIT
;
unsigned
in
t
i
;
size_
t
i
;
git_buf
pack_file_path
=
GIT_BUF_INIT
;
git_vector
packing_list
;
unsigned
int
total_refs
;
...
...
src/reflog.c
View file @
50eb8520
...
...
@@ -163,7 +163,7 @@ fail:
void
git_reflog_free
(
git_reflog
*
reflog
)
{
unsigned
in
t
i
;
size_
t
i
;
git_reflog_entry
*
entry
;
if
(
reflog
==
NULL
)
...
...
src/refs.c
View file @
50eb8520
...
...
@@ -440,6 +440,7 @@ int git_reference_rename(
git_oid
*
oid
;
const
char
*
symbolic
;
int
error
=
0
;
int
reference_has_log
;
*
out
=
NULL
;
...
...
@@ -465,11 +466,13 @@ int git_reference_rename(
return
-
1
;
/* Check if we have to update HEAD. */
if
((
should_head_be_updated
=
git_branch_is_head
(
ref
))
<
0
)
if
((
error
=
git_branch_is_head
(
ref
))
<
0
)
goto
on_error
;
should_head_be_updated
=
(
error
>
0
);
/* Now delete the old ref and save the new one. */
if
(
git_refdb_delete
(
ref
->
db
,
ref
)
<
0
)
if
(
(
error
=
git_refdb_delete
(
ref
->
db
,
ref
)
)
<
0
)
goto
on_error
;
/* Save the new reference. */
...
...
@@ -477,14 +480,18 @@ int git_reference_rename(
goto
rollback
;
/* Update HEAD it was poiting to the reference being renamed. */
if
(
should_head_be_updated
&&
git_repository_set_head
(
ref
->
db
->
repo
,
new_name
)
<
0
)
{
if
(
should_head_be_updated
&&
(
error
=
git_repository_set_head
(
ref
->
db
->
repo
,
new_name
)
)
<
0
)
{
giterr_set
(
GITERR_REFERENCE
,
"Failed to update HEAD after renaming reference"
);
goto
on_error
;
}
/* Rename the reflog file, if it exists. */
if
(
git_reference_has_log
(
ref
)
&&
(
error
=
git_reflog_rename
(
ref
,
new_name
))
<
0
)
reference_has_log
=
git_reference_has_log
(
ref
);
if
(
reference_has_log
<
0
)
{
error
=
reference_has_log
;
goto
on_error
;
}
if
(
reference_has_log
&&
(
error
=
git_reflog_rename
(
ref
,
new_name
))
<
0
)
goto
on_error
;
*
out
=
result
;
...
...
src/remote.c
View file @
50eb8520
...
...
@@ -1254,7 +1254,7 @@ static int rename_fetch_refspecs(
goto
cleanup
;
/* Is it an in-memory remote? */
if
(
remote
->
name
==
'\0'
)
{
if
(
!
remote
->
name
)
{
error
=
(
callback
(
git_buf_cstr
(
&
serialized
),
payload
)
<
0
)
?
GIT_EUSER
:
0
;
goto
cleanup
;
}
...
...
src/revparse.c
View file @
50eb8520
...
...
@@ -511,8 +511,8 @@ static int walk_and_search(git_object **out, git_revwalk *walk, regex_t *regex)
while
(
!
(
error
=
git_revwalk_next
(
&
oid
,
walk
)))
{
if
((
error
=
git_object_lookup
(
&
obj
,
git_revwalk_repository
(
walk
),
&
oid
,
GIT_OBJ_COMMIT
)
<
0
)
&&
(
error
!=
GIT_ENOTFOUND
))
error
=
git_object_lookup
(
&
obj
,
git_revwalk_repository
(
walk
),
&
oid
,
GIT_OBJ_COMMIT
);
if
((
error
<
0
)
&&
(
error
!=
GIT_ENOTFOUND
))
return
-
1
;
if
(
!
regexec
(
regex
,
git_commit_message
((
git_commit
*
)
obj
),
0
,
NULL
,
0
))
{
...
...
@@ -635,7 +635,7 @@ static int extract_how_many(int *n, const char *spec, size_t *pos)
}
while
(
spec
[(
*
pos
)]
==
kind
&&
kind
==
'~'
);
if
(
git__isdigit
(
spec
[
*
pos
]))
{
if
(
(
git__strtol32
(
&
parsed
,
spec
+
*
pos
,
&
end_ptr
,
10
)
<
0
)
<
0
)
if
(
git__strtol32
(
&
parsed
,
spec
+
*
pos
,
&
end_ptr
,
1
0
)
<
0
)
return
GIT_EINVALIDSPEC
;
accumulated
+=
(
parsed
-
1
);
...
...
src/submodule.c
View file @
50eb8520
...
...
@@ -1497,7 +1497,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
if
(
untracked
>
0
)
*
status
|=
GIT_SUBMODULE_STATUS_WD_UNTRACKED
;
if
(
(
git_diff_num_deltas
(
diff
)
-
untracked
)
>
0
)
if
(
git_diff_num_deltas
(
diff
)
!=
untracked
)
*
status
|=
GIT_SUBMODULE_STATUS_WD_WD_MODIFIED
;
git_diff_list_free
(
diff
);
...
...
src/transports/local.c
View file @
50eb8520
...
...
@@ -124,7 +124,7 @@ static int store_refs(transport_local *t)
assert
(
t
);
if
(
git_reference_list
(
&
ref_names
,
t
->
repo
,
GIT_REF_LISTALL
)
<
0
||
git_vector_init
(
&
t
->
refs
,
(
unsigned
int
)
ref_names
.
count
,
NULL
)
<
0
)
git_vector_init
(
&
t
->
refs
,
ref_names
.
count
,
NULL
)
<
0
)
goto
on_error
;
/* Sort the references first */
...
...
src/transports/smart.c
View file @
50eb8520
...
...
@@ -24,7 +24,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
buf
->
offset
+=
bytes_read
;
if
(
t
->
packetsize_cb
)
t
->
packetsize_cb
(
(
int
)
bytes_read
,
t
->
packetsize_payload
);
t
->
packetsize_cb
(
bytes_read
,
t
->
packetsize_payload
);
return
(
int
)(
buf
->
offset
-
old_len
);
}
...
...
src/transports/smart_protocol.c
View file @
50eb8520
...
...
@@ -454,7 +454,7 @@ int git_smart__download_pack(
/* We might have something in the buffer already from negotiate_fetch */
if
(
t
->
buffer
.
offset
>
0
)
t
->
packetsize_cb
(
(
int
)
t
->
buffer
.
offset
,
t
->
packetsize_payload
);
t
->
packetsize_cb
(
t
->
buffer
.
offset
,
t
->
packetsize_payload
);
}
if
((
error
=
git_repository_odb__weakptr
(
&
odb
,
repo
))
<
0
||
...
...
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