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
77394a27
Commit
77394a27
authored
Mar 14, 2016
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3677 from pks-t/pks/coverity-fixes-round7
Coverity fixes round 7
parents
4848dd32
13c371dc
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
14 deletions
+39
-14
src/blame.c
+8
-3
src/blame_git.c
+2
-1
src/config_cache.c
+2
-1
src/config_file.c
+20
-8
src/filebuf.c
+6
-1
src/refdb_fs.c
+1
-0
No files found.
src/blame.c
View file @
77394a27
...
...
@@ -178,7 +178,7 @@ const git_blame_hunk *git_blame_get_hunk_byline(git_blame *blame, size_t lineno)
return
NULL
;
}
static
void
normalize_options
(
static
int
normalize_options
(
git_blame_options
*
out
,
const
git_blame_options
*
in
,
git_repository
*
repo
)
...
...
@@ -190,7 +190,9 @@ static void normalize_options(
/* No newest_commit => HEAD */
if
(
git_oid_iszero
(
&
out
->
newest_commit
))
{
git_reference_name_to_id
(
&
out
->
newest_commit
,
repo
,
"HEAD"
);
if
(
git_reference_name_to_id
(
&
out
->
newest_commit
,
repo
,
"HEAD"
)
<
0
)
{
return
-
1
;
}
}
/* min_line 0 really means 1 */
...
...
@@ -204,6 +206,8 @@ static void normalize_options(
out
->
flags
|=
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES
;
if
(
out
->
flags
&
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES
)
out
->
flags
|=
GIT_BLAME_TRACK_COPIES_SAME_FILE
;
return
0
;
}
static
git_blame_hunk
*
split_hunk_in_vector
(
...
...
@@ -362,7 +366,8 @@ int git_blame_file(
git_blame
*
blame
=
NULL
;
assert
(
out
&&
repo
&&
path
);
normalize_options
(
&
normOptions
,
options
,
repo
);
if
((
error
=
normalize_options
(
&
normOptions
,
options
,
repo
))
<
0
)
goto
on_error
;
blame
=
git_blame__alloc
(
repo
,
normOptions
,
path
);
GITERR_CHECK_ALLOC
(
blame
);
...
...
src/blame_git.c
View file @
77394a27
...
...
@@ -525,7 +525,8 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
if
(
sg_origin
[
i
])
continue
;
git_commit_parent
(
&
p
,
origin
->
commit
,
i
);
if
((
error
=
git_commit_parent
(
&
p
,
origin
->
commit
,
i
))
<
0
)
goto
finish
;
porigin
=
find_origin
(
blame
,
p
,
origin
);
if
(
!
porigin
)
...
...
src/config_cache.c
View file @
77394a27
...
...
@@ -86,7 +86,8 @@ int git_config__cvar(int *out, git_config *config, git_cvar_cached cvar)
struct
map_data
*
data
=
&
_cvar_maps
[(
int
)
cvar
];
git_config_entry
*
entry
;
git_config__lookup_entry
(
&
entry
,
config
,
data
->
cvar_name
,
false
);
if
((
error
=
git_config__lookup_entry
(
&
entry
,
config
,
data
->
cvar_name
,
false
))
<
0
)
return
error
;
if
(
!
entry
)
*
out
=
data
->
default_value
;
...
...
src/config_file.c
View file @
77394a27
...
...
@@ -232,7 +232,10 @@ static refcounted_strmap *refcounted_strmap_take(diskfile_header *h)
{
refcounted_strmap
*
map
;
git_mutex_lock
(
&
h
->
values_mutex
);
if
(
git_mutex_lock
(
&
h
->
values_mutex
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"Failed to lock config backend"
);
return
NULL
;
}
map
=
h
->
values
;
git_atomic_inc
(
&
map
->
refcount
);
...
...
@@ -318,7 +321,10 @@ static int config__refresh(git_config_backend *cfg)
if
((
error
=
config_read
(
values
->
values
,
b
,
reader
,
b
->
level
,
0
))
<
0
)
goto
out
;
git_mutex_lock
(
&
b
->
header
.
values_mutex
);
if
((
error
=
git_mutex_lock
(
&
b
->
header
.
values_mutex
))
<
0
)
{
giterr_set
(
GITERR_OS
,
"Failed to lock config backend"
);
goto
out
;
}
tmp
=
b
->
header
.
values
;
b
->
header
.
values
=
values
;
...
...
@@ -460,7 +466,8 @@ static int config_set(git_config_backend *cfg, const char *name, const char *val
if
((
rval
=
git_config__normalize_name
(
name
,
&
key
))
<
0
)
return
rval
;
map
=
refcounted_strmap_take
(
&
b
->
header
);
if
((
map
=
refcounted_strmap_take
(
&
b
->
header
))
==
NULL
)
return
-
1
;
values
=
map
->
values
;
/*
...
...
@@ -527,7 +534,8 @@ static int config_get(git_config_backend *cfg, const char *key, git_config_entry
if
(
!
h
->
parent
.
readonly
&&
((
error
=
config_refresh
(
cfg
))
<
0
))
return
error
;
map
=
refcounted_strmap_take
(
h
);
if
((
map
=
refcounted_strmap_take
(
h
))
==
NULL
)
return
-
1
;
values
=
map
->
values
;
pos
=
git_strmap_lookup_index
(
values
,
key
);
...
...
@@ -565,7 +573,8 @@ static int config_set_multivar(
if
((
result
=
git_config__normalize_name
(
name
,
&
key
))
<
0
)
return
result
;
map
=
refcounted_strmap_take
(
&
b
->
header
);
if
((
map
=
refcounted_strmap_take
(
&
b
->
header
))
==
NULL
)
return
-
1
;
values
=
b
->
header
.
values
->
values
;
pos
=
git_strmap_lookup_index
(
values
,
key
);
...
...
@@ -610,7 +619,8 @@ static int config_delete(git_config_backend *cfg, const char *name)
if
((
result
=
git_config__normalize_name
(
name
,
&
key
))
<
0
)
return
result
;
map
=
refcounted_strmap_take
(
&
b
->
header
);
if
((
map
=
refcounted_strmap_take
(
&
b
->
header
))
==
NULL
)
return
-
1
;
values
=
b
->
header
.
values
->
values
;
pos
=
git_strmap_lookup_index
(
values
,
key
);
...
...
@@ -649,7 +659,8 @@ static int config_delete_multivar(git_config_backend *cfg, const char *name, con
if
((
result
=
git_config__normalize_name
(
name
,
&
key
))
<
0
)
return
result
;
map
=
refcounted_strmap_take
(
&
b
->
header
);
if
((
map
=
refcounted_strmap_take
(
&
b
->
header
))
==
NULL
)
return
-
1
;
values
=
b
->
header
.
values
->
values
;
pos
=
git_strmap_lookup_index
(
values
,
key
);
...
...
@@ -832,7 +843,8 @@ static int config_readonly_open(git_config_backend *cfg, git_config_level_t leve
/* We're just copying data, don't care about the level */
GIT_UNUSED
(
level
);
src_map
=
refcounted_strmap_take
(
src_header
);
if
((
src_map
=
refcounted_strmap_take
(
src_header
))
==
NULL
)
return
-
1
;
b
->
header
.
values
=
src_map
;
return
0
;
...
...
src/filebuf.c
View file @
77394a27
...
...
@@ -70,6 +70,7 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
git_file
source
;
char
buffer
[
FILEIO_BUFSIZE
];
ssize_t
read_bytes
;
int
error
;
source
=
p_open
(
file
->
path_original
,
O_RDONLY
);
if
(
source
<
0
)
{
...
...
@@ -80,7 +81,8 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
}
while
((
read_bytes
=
p_read
(
source
,
buffer
,
sizeof
(
buffer
)))
>
0
)
{
p_write
(
file
->
fd
,
buffer
,
read_bytes
);
if
((
error
=
p_write
(
file
->
fd
,
buffer
,
read_bytes
))
<
0
)
break
;
if
(
file
->
compute_digest
)
git_hash_update
(
&
file
->
digest
,
buffer
,
read_bytes
);
}
...
...
@@ -90,6 +92,9 @@ static int lock_file(git_filebuf *file, int flags, mode_t mode)
if
(
read_bytes
<
0
)
{
giterr_set
(
GITERR_OS
,
"Failed to read file '%s'"
,
file
->
path_original
);
return
-
1
;
}
else
if
(
error
<
0
)
{
giterr_set
(
GITERR_OS
,
"Failed to write file '%s'"
,
file
->
path_lock
);
return
-
1
;
}
}
...
...
src/refdb_fs.c
View file @
77394a27
...
...
@@ -962,6 +962,7 @@ static int packed_write(refdb_fs_backend *backend)
for
(
i
=
0
;
i
<
git_sortedcache_entrycount
(
refcache
);
++
i
)
{
struct
packref
*
ref
=
git_sortedcache_entry
(
refcache
,
i
);
assert
(
ref
);
if
(
packed_find_peel
(
backend
,
ref
)
<
0
)
goto
fail
;
...
...
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