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
0b2c4061
Commit
0b2c4061
authored
Aug 30, 2011
by
Kirill A. Shutemov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMakefile: add -Wstrict-aliasing=2 and fix warnings
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
parent
2fcf9c82
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
8 deletions
+11
-8
CMakeLists.txt
+1
-1
src/cache.c
+6
-6
src/tree.c
+4
-1
No files found.
CMakeLists.txt
View file @
0b2c4061
...
@@ -57,7 +57,7 @@ IF (MSVC)
...
@@ -57,7 +57,7 @@ IF (MSVC)
SET
(
CMAKE_C_FLAGS_DEBUG
"/Od /DEBUG /MTd"
)
SET
(
CMAKE_C_FLAGS_DEBUG
"/Od /DEBUG /MTd"
)
SET
(
CMAKE_C_FLAGS_RELEASE
"/MT /O2"
)
SET
(
CMAKE_C_FLAGS_RELEASE
"/MT /O2"
)
ELSE
()
ELSE
()
SET
(
CMAKE_C_FLAGS
"-O2 -g -Wall -Wextra"
)
SET
(
CMAKE_C_FLAGS
"-O2 -g -Wall -Wextra
-Wstrict-aliasing=2
"
)
IF
(
NOT MINGW
)
# MinGW always does PIC and complains if we tell it to
IF
(
NOT MINGW
)
# MinGW always does PIC and complains if we tell it to
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fPIC"
)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-fPIC"
)
ENDIF
()
ENDIF
()
...
...
src/cache.c
View file @
0b2c4061
...
@@ -76,12 +76,12 @@ void git_cache_free(git_cache *cache)
...
@@ -76,12 +76,12 @@ void git_cache_free(git_cache *cache)
void
*
git_cache_get
(
git_cache
*
cache
,
const
git_oid
*
oid
)
void
*
git_cache_get
(
git_cache
*
cache
,
const
git_oid
*
oid
)
{
{
const
uint32_t
*
hash
;
uint32_t
hash
;
cache_node
*
node
=
NULL
;
cache_node
*
node
=
NULL
;
void
*
result
=
NULL
;
void
*
result
=
NULL
;
hash
=
(
const
uint32_t
*
)
oid
->
id
;
memcpy
(
&
hash
,
oid
->
id
,
sizeof
(
hash
))
;
node
=
&
cache
->
nodes
[
hash
[
0
]
&
cache
->
size_mask
];
node
=
&
cache
->
nodes
[
hash
&
cache
->
size_mask
];
git_mutex_lock
(
&
node
->
lock
);
git_mutex_lock
(
&
node
->
lock
);
{
{
...
@@ -97,13 +97,13 @@ void *git_cache_get(git_cache *cache, const git_oid *oid)
...
@@ -97,13 +97,13 @@ void *git_cache_get(git_cache *cache, const git_oid *oid)
void
*
git_cache_try_store
(
git_cache
*
cache
,
void
*
entry
)
void
*
git_cache_try_store
(
git_cache
*
cache
,
void
*
entry
)
{
{
const
uint32_t
*
hash
;
uint32_t
hash
;
const
git_oid
*
oid
;
const
git_oid
*
oid
;
cache_node
*
node
=
NULL
;
cache_node
*
node
=
NULL
;
oid
=
&
((
git_cached_obj
*
)
entry
)
->
oid
;
oid
=
&
((
git_cached_obj
*
)
entry
)
->
oid
;
hash
=
(
const
uint32_t
*
)
oid
->
id
;
memcpy
(
&
hash
,
oid
->
id
,
sizeof
(
hash
))
;
node
=
&
cache
->
nodes
[
hash
[
0
]
&
cache
->
size_mask
];
node
=
&
cache
->
nodes
[
hash
&
cache
->
size_mask
];
/* 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/tree.c
View file @
0b2c4061
...
@@ -175,6 +175,7 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
...
@@ -175,6 +175,7 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
while
(
buffer
<
buffer_end
)
{
while
(
buffer
<
buffer_end
)
{
git_tree_entry
*
entry
;
git_tree_entry
*
entry
;
long
tmp
;
entry
=
git__calloc
(
1
,
sizeof
(
git_tree_entry
));
entry
=
git__calloc
(
1
,
sizeof
(
git_tree_entry
));
if
(
entry
==
NULL
)
{
if
(
entry
==
NULL
)
{
...
@@ -185,8 +186,10 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
...
@@ -185,8 +186,10 @@ static int tree_parse_buffer(git_tree *tree, const char *buffer, const char *buf
if
(
git_vector_insert
(
&
tree
->
entries
,
entry
)
<
GIT_SUCCESS
)
if
(
git_vector_insert
(
&
tree
->
entries
,
entry
)
<
GIT_SUCCESS
)
return
GIT_ENOMEM
;
return
GIT_ENOMEM
;
if
(
git__strtol32
((
long
*
)
&
entry
->
attr
,
buffer
,
&
buffer
,
8
)
<
GIT_SUCCESS
)
if
(
git__strtol32
(
&
tmp
,
buffer
,
&
buffer
,
8
)
<
GIT_SUCCESS
||
!
buffer
||
tmp
>
UINT_MAX
||
tmp
<
0
)
return
git__throw
(
GIT_EOBJCORRUPTED
,
"Failed to parse tree. Can't parse attributes"
);
return
git__throw
(
GIT_EOBJCORRUPTED
,
"Failed to parse tree. Can't parse attributes"
);
entry
->
attr
=
tmp
;
if
(
*
buffer
++
!=
' '
)
{
if
(
*
buffer
++
!=
' '
)
{
error
=
git__throw
(
GIT_EOBJCORRUPTED
,
"Failed to parse tree. Object it corrupted"
);
error
=
git__throw
(
GIT_EOBJCORRUPTED
,
"Failed to parse tree. Object it corrupted"
);
...
...
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