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
6a7f0403
Unverified
Commit
6a7f0403
authored
Jul 16, 2021
by
Edward Thomson
Committed by
GitHub
Jul 16, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5941 from NattyNarwhal/stdintification
stdintification: use int64_t and INT64_C instead of long long
parents
36e80306
d6bea53d
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
258 additions
and
267 deletions
+258
-267
src/commit_graph.c
+1
-1
src/diff_xdiff.h
+1
-1
src/hash/sha1/generic.h
+1
-1
src/hashsig.c
+1
-1
src/integer.h
+2
-2
src/khash.h
+2
-11
src/mwindow.c
+1
-1
src/util.h
+1
-1
src/win32/w32_util.h
+6
-6
tests/core/encoding.c
+3
-3
tests/core/integer.c
+231
-231
tests/core/strtol.c
+4
-4
tests/graph/commit_graph.c
+3
-3
tests/revwalk/basic.c
+1
-1
No files found.
src/commit_graph.c
View file @
6a7f0403
...
...
@@ -304,7 +304,7 @@ static int git_commit_graph_entry_get_byindex(
e
->
generation
=
ntohl
(
*
((
uint32_t
*
)(
commit_data
+
GIT_OID_RAWSZ
+
2
*
sizeof
(
uint32_t
))));
e
->
commit_time
=
ntohl
(
*
((
uint32_t
*
)(
commit_data
+
GIT_OID_RAWSZ
+
3
*
sizeof
(
uint32_t
))));
e
->
commit_time
|=
(
e
->
generation
&
0x3ull
)
<<
32ull
;
e
->
commit_time
|=
(
e
->
generation
&
UINT64_C
(
0x3
))
<<
UINT64_C
(
32
)
;
e
->
generation
>>=
2u
;
if
(
e
->
parent_indices
[
1
]
&
0x80000000u
)
{
uint32_t
extra_edge_list_pos
=
e
->
parent_indices
[
1
]
&
0x7fffffff
;
...
...
src/diff_xdiff.h
View file @
6a7f0403
...
...
@@ -16,7 +16,7 @@
/* xdiff cannot cope with large files. these files should not be passed to
* xdiff. callers should treat these large files as binary.
*/
#define GIT_XDIFF_MAX_SIZE (
1024LL
* 1024 * 1023)
#define GIT_XDIFF_MAX_SIZE (
INT64_C(1024)
* 1024 * 1023)
/* A git_xdiff_output is a git_patch_generate_output with extra fields
* necessary to use libxdiff. Calling git_xdiff_init() will set the diff_cb
...
...
src/hash/sha1/generic.h
View file @
6a7f0403
...
...
@@ -11,7 +11,7 @@
#include "hash/sha1.h"
struct
git_hash_sha1_ctx
{
u
nsigned
long
long
size
;
u
int64_t
size
;
unsigned
int
H
[
5
];
unsigned
int
W
[
16
];
};
...
...
src/hashsig.c
View file @
6a7f0403
...
...
@@ -17,7 +17,7 @@ typedef uint64_t hashsig_state;
#define HASHSIG_SCALE 100
#define HASHSIG_MAX_RUN 80
#define HASHSIG_HASH_START
0x012345678ABCDEF0LL
#define HASHSIG_HASH_START
INT64_C(0x012345678ABCDEF0)
#define HASHSIG_HASH_SHIFT 5
#define HASHSIG_HASH_MIX(S,CH) \
...
...
src/integer.h
View file @
6a7f0403
...
...
@@ -43,10 +43,10 @@ GIT_INLINE(int) git__is_ulong(int64_t p)
}
/** @return true if p fits into the range of an int */
GIT_INLINE
(
int
)
git__is_int
(
long
long
p
)
GIT_INLINE
(
int
)
git__is_int
(
int64_t
p
)
{
int
r
=
(
int
)
p
;
return
p
==
(
long
long
)
r
;
return
p
==
(
int64_t
)
r
;
}
/* Use clang/gcc compiler intrinsics whenever possible */
...
...
src/khash.h
View file @
6a7f0403
...
...
@@ -131,17 +131,8 @@ int main() {
/* compiler specific configuration */
#if UINT_MAX == 0xffffffffu
typedef
unsigned
int
khint32_t
;
#elif ULONG_MAX == 0xffffffffu
typedef
unsigned
long
khint32_t
;
#endif
#if ULONG_MAX == ULLONG_MAX
typedef
unsigned
long
khint64_t
;
#else
typedef
unsigned
long
long
khint64_t
;
#endif
typedef
uint32_t
khint32_t
;
typedef
uint64_t
khint64_t
;
#ifndef kh_inline
#ifdef _MSC_VER
...
...
src/mwindow.c
View file @
6a7f0403
...
...
@@ -20,7 +20,7 @@
: 32 * 1024 * 1024)
#define DEFAULT_MAPPED_LIMIT \
((1024 * 1024) * (sizeof(void*) >= 8 ?
8192ULL : 256UL
))
((1024 * 1024) * (sizeof(void*) >= 8 ?
UINT64_C(8192) : UINT64_C(256)
))
/* default is unlimited */
#define DEFAULT_FILE_LIMIT 0
...
...
src/util.h
View file @
6a7f0403
...
...
@@ -22,7 +22,7 @@
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define bitsizeof(x) (CHAR_BIT * sizeof(x))
#define MSB(x, bits) ((x) & (~
0ULL
<< (bitsizeof(x) - (bits))))
#define MSB(x, bits) ((x) & (~
UINT64_C(0)
<< (bitsizeof(x) - (bits))))
#ifndef min
# define min(a,b) ((a) < (b) ? (a) : (b))
#endif
...
...
src/win32/w32_util.h
View file @
6a7f0403
...
...
@@ -74,8 +74,8 @@ GIT_INLINE(void) git_win32__filetime_to_timespec(
const
FILETIME
*
ft
,
struct
timespec
*
ts
)
{
long
long
winTime
=
((
long
long
)
ft
->
dwHighDateTime
<<
32
)
+
ft
->
dwLowDateTime
;
winTime
-=
116444736000000000LL
;
/* Windows to Unix Epoch conversion */
int64_t
winTime
=
((
int64_t
)
ft
->
dwHighDateTime
<<
32
)
+
ft
->
dwLowDateTime
;
winTime
-=
INT64_C
(
116444736000000000
)
;
/* Windows to Unix Epoch conversion */
ts
->
tv_sec
=
(
time_t
)(
winTime
/
10000000
);
#ifdef GIT_USE_NSEC
ts
->
tv_nsec
=
(
winTime
%
10000000
)
*
100
;
...
...
@@ -87,11 +87,11 @@ GIT_INLINE(void) git_win32__filetime_to_timespec(
GIT_INLINE
(
void
)
git_win32__timeval_to_filetime
(
FILETIME
*
ft
,
const
struct
p_timeval
tv
)
{
long
long
ticks
=
(
tv
.
tv_sec
*
10000000LL
)
+
(
tv
.
tv_usec
*
10LL
)
+
116444736000000000LL
;
int64_t
ticks
=
(
tv
.
tv_sec
*
INT64_C
(
10000000
)
)
+
(
tv
.
tv_usec
*
INT64_C
(
10
))
+
INT64_C
(
116444736000000000
)
;
ft
->
dwHighDateTime
=
((
ticks
>>
32
)
&
0xffffffffLL
);
ft
->
dwLowDateTime
=
(
ticks
&
0xffffffffLL
);
ft
->
dwHighDateTime
=
((
ticks
>>
32
)
&
INT64_C
(
0xffffffff
)
);
ft
->
dwLowDateTime
=
(
ticks
&
INT64_C
(
0xffffffff
)
);
}
GIT_INLINE
(
void
)
git_win32__stat_init
(
...
...
tests/core/encoding.c
View file @
6a7f0403
...
...
@@ -14,7 +14,7 @@ void test_core_encoding__decode(void)
cl_assert
(
size
==
4
);
buf
=
(
unsigned
char
*
)
"
\xaa\xaa\xfe\xdc\xba
XY"
;
cl_assert
(
git_decode_varint
(
buf
,
&
size
)
==
1489279344088ULL
);
cl_assert
(
git_decode_varint
(
buf
,
&
size
)
==
UINT64_C
(
1489279344088
)
);
cl_assert
(
size
==
6
);
buf
=
(
unsigned
char
*
)
"
\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xfe\xdc\xba
XY"
;
...
...
@@ -35,8 +35,8 @@ void test_core_encoding__encode(void)
cl_assert
(
git_encode_varint
(
buf
,
100
,
267869656
)
==
4
);
cl_assert
(
!
memcmp
(
buf
,
"
\xfe\xdc\xba
X"
,
4
));
cl_assert
(
git_encode_varint
(
buf
,
100
,
1489279344088ULL
)
==
6
);
cl_assert
(
git_encode_varint
(
buf
,
100
,
UINT64_C
(
1489279344088
)
)
==
6
);
cl_assert
(
!
memcmp
(
buf
,
"
\xaa\xaa\xfe\xdc\xba
X"
,
6
));
cl_assert
(
git_encode_varint
(
buf
,
1
,
1489279344088ULL
)
==
-
1
);
cl_assert
(
git_encode_varint
(
buf
,
1
,
UINT64_C
(
1489279344088
)
)
==
-
1
);
}
tests/core/integer.c
View file @
6a7f0403
...
...
@@ -4,168 +4,168 @@ void test_core_integer__multiply_int64_no_overflow(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t
result
=
0
;
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
0x1ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
0x2ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
-
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
-
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
0x7fffffffffffffffll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
-
0x7fffffffffffffffll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x0ll
,
-
0x8000000000000000ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
0x1ll
));
cl_assert_equal_i
(
result
,
0x1ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x1ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
0x2ll
));
cl_assert_equal_i
(
result
,
0x2ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
-
0x2ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
0x7ffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
-
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
-
0x7ffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
0x800000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
-
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
-
0x800000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
0x7fffffffffffffffll
));
cl_assert_equal_i
(
result
,
0x7fffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
-
0x7fffffffffffffffll
));
cl_assert_equal_i
(
result
,
-
0x7fffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x1ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
0x1ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
0x2ll
));
cl_assert_equal_i
(
result
,
-
0x2ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
0x2ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
-
0x7ffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
-
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
0x7ffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
-
0x800000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
-
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
0x800000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
0x7fffffffffffffffll
));
cl_assert_equal_i
(
result
,
-
0x7fffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
-
0x7fffffffffffffffll
));
cl_assert_equal_i
(
result
,
0x7fffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
0x1ll
));
cl_assert_equal_i
(
result
,
0x2ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x2ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
0x2ll
));
cl_assert_equal_i
(
result
,
0x4ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
-
0x4ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
0xffffffffffffffell
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
-
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
-
0xffffffffffffffell
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
0x1000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
-
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
-
0x1000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x2ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
0x2ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
0x2ll
));
cl_assert_equal_i
(
result
,
-
0x4ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
0x4ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
-
0xffffffffffffffell
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
-
0x7ffffffffffffffll
));
cl_assert_equal_i
(
result
,
0xffffffffffffffell
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
-
0x1000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
-
0x800000000000000ll
));
cl_assert_equal_i
(
result
,
0x1000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
-
0x4000000000000000ll
));
cl_assert_equal_i
(
result
,
-
0x8000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
0x1ll
));
cl_assert_equal_i
(
result
,
0x7ffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x7ffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
0x2ll
));
cl_assert_equal_i
(
result
,
0xffffffffffffffell
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
-
0xffffffffffffffell
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x7ffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
0x7ffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
0x2ll
));
cl_assert_equal_i
(
result
,
-
0xffffffffffffffell
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
0xffffffffffffffell
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
0x1ll
));
cl_assert_equal_i
(
result
,
0x800000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x800000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
0x2ll
));
cl_assert_equal_i
(
result
,
0x1000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
-
0x1000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x800000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
0x800000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
0x2ll
));
cl_assert_equal_i
(
result
,
-
0x1000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
-
0x2ll
));
cl_assert_equal_i
(
result
,
0x1000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
0x1ll
));
cl_assert_equal_i
(
result
,
0x7fffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x7fffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x4000000000000000ll
,
0x2ll
));
cl_assert_equal_i
(
result
,
-
0x8000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x7fffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
0x7fffffffffffffffll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
0x0ll
));
cl_assert_equal_i
(
result
,
0x0ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x0
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x1
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x1
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x2
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x2
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x7ffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x7ffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x800000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x800000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x7fffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x7fffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x1
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x1
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x2
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x2
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x7ffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x7ffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x800000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x800000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x7fffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x7fffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x2
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x2
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x4
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x4
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0xffffffffffffffe
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0xffffffffffffffe
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x1000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x1000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x2
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x2
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x4
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x4
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0xffffffffffffffe
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0xffffffffffffffe
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x1000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x1000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
-
0x4000000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x8000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x7ffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x7ffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0xffffffffffffffe
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0xffffffffffffffe
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x7ffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x7ffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0xffffffffffffffe
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0xffffffffffffffe
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x800000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x800000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x1000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x1000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x800000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x800000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x1000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
-
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x1000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x7fffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x7fffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x4000000000000000
),
INT64_C
(
0x2
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x8000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x7fffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x7fffffffffffffff
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
0x0
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
0x0
)
);
#endif
}
...
...
@@ -173,69 +173,69 @@ void test_core_integer__multiply_int64_overflow(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t
result
=
0
;
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
0x4000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x2ll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x2ll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
-
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
-
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7ffffffffffffffll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
-
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
-
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7ffffffffffffffll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
-
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
-
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x800000000000000ll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
-
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
-
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x800000000000000ll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x4000000000000000ll
,
0x2ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
0x2ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
-
0x2ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
-
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
-
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x7fffffffffffffffll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
0x2ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
-
0x2ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
-
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
-
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x7fffffffffffffffll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
0x2ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
-
0x2ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
-
0x7ffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
-
0x800000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
-
0x7fffffffffffffffll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
0x4000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x2
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x2
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7ffffffffffffff
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7ffffffffffffff
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x800000000000000
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x800000000000000
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x4000000000000000
),
INT64_C
(
0x2
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
0x2
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
-
0x2
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x7fffffffffffffff
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
0x2
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
-
0x2
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x7fffffffffffffff
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
0x2
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
-
0x2
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
-
0x7ffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
-
0x800000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
-
0x7fffffffffffffff
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
-
0x8000000000000000
)
));
#endif
}
...
...
@@ -243,11 +243,11 @@ void test_core_integer__multiply_int64_edge_cases(void)
{
#if !defined(git__multiply_int64_overflow)
int64_t
result
=
0
;
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
-
0x1ll
));
cl_assert_equal_i
(
result
,
-
0x8000000000000000ll
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
-
0x1ll
,
-
0x8000000000000000ll
));
cl_assert_equal_i
(
result
,
-
0x8000000000000000ll
);
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
0x1ll
,
-
0x8000000000000000ll
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
-
0x8000000000000000ll
,
0x1ll
));
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
-
0x1
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x8000000000000000
)
);
cl_assert
(
!
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x1
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert_equal_i
(
result
,
INT64_C
(
-
0x8000000000000000
)
);
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
0x1
),
INT64_C
(
-
0x8000000000000000
)
));
cl_assert
(
git__multiply_int64_overflow
(
&
result
,
INT64_C
(
-
0x8000000000000000
),
INT64_C
(
0x1
)
));
#endif
}
tests/core/strtol.c
View file @
6a7f0403
...
...
@@ -32,7 +32,7 @@ void test_core_strtol__int32(void)
assert_l32_parses
(
" +123 "
,
123
,
10
);
assert_l32_parses
(
" -123 "
,
-
123
,
10
);
assert_l32_parses
(
" +2147483647 "
,
2147483647
,
10
);
assert_l32_parses
(
" -2147483648 "
,
-
2147483648LL
,
10
);
assert_l32_parses
(
" -2147483648 "
,
INT64_C
(
-
2147483648
)
,
10
);
assert_l32_parses
(
"A"
,
10
,
16
);
assert_l32_parses
(
"1x1"
,
1
,
10
);
...
...
@@ -49,9 +49,9 @@ void test_core_strtol__int64(void)
assert_l64_parses
(
" +123 "
,
123
,
10
);
assert_l64_parses
(
" -123 "
,
-
123
,
10
);
assert_l64_parses
(
" +2147483647 "
,
2147483647
,
10
);
assert_l64_parses
(
" -2147483648 "
,
-
2147483648LL
,
10
);
assert_l64_parses
(
" 2147483657 "
,
2147483657LL
,
10
);
assert_l64_parses
(
" -2147483657 "
,
-
2147483657LL
,
10
);
assert_l64_parses
(
" -2147483648 "
,
INT64_C
(
-
2147483648
)
,
10
);
assert_l64_parses
(
" 2147483657 "
,
INT64_C
(
2147483657
)
,
10
);
assert_l64_parses
(
" -2147483657 "
,
INT64_C
(
-
2147483657
)
,
10
);
assert_l64_parses
(
" 9223372036854775807 "
,
INT64_MAX
,
10
);
assert_l64_parses
(
" -9223372036854775808 "
,
INT64_MIN
,
10
);
assert_l64_parses
(
" 0x7fffffffffffffff "
,
INT64_MAX
,
16
);
...
...
tests/graph/commit_graph.c
View file @
6a7f0403
...
...
@@ -23,14 +23,14 @@ void test_graph_commit_graph__parse(void)
cl_git_pass
(
git_oid_fromstr
(
&
id
,
"418382dff1ffb8bdfba833f4d8bbcde58b1e7f47"
));
cl_assert_equal_oid
(
&
e
.
tree_oid
,
&
id
);
cl_assert_equal_i
(
e
.
generation
,
1
);
cl_assert_equal_i
(
e
.
commit_time
,
1273610423ull
);
cl_assert_equal_i
(
e
.
commit_time
,
UINT64_C
(
1273610423
)
);
cl_assert_equal_i
(
e
.
parent_count
,
0
);
cl_git_pass
(
git_oid_fromstr
(
&
id
,
"be3563ae3f795b2b4353bcce3a527ad0a4f7f644"
));
cl_git_pass
(
git_commit_graph_entry_find
(
&
e
,
cgraph
,
&
id
,
GIT_OID_HEXSZ
));
cl_assert_equal_oid
(
&
e
.
sha1
,
&
id
);
cl_assert_equal_i
(
e
.
generation
,
5
);
cl_assert_equal_i
(
e
.
commit_time
,
1274813907ull
);
cl_assert_equal_i
(
e
.
commit_time
,
UINT64_C
(
1274813907
)
);
cl_assert_equal_i
(
e
.
parent_count
,
2
);
cl_git_pass
(
git_oid_fromstr
(
&
id
,
"9fd738e8f7967c078dceed8190330fc8648ee56a"
));
...
...
@@ -66,7 +66,7 @@ void test_graph_commit_graph__parse_octopus_merge(void)
cl_git_pass
(
git_oid_fromstr
(
&
id
,
"348f16ffaeb73f319a75cec5b16a0a47d2d5e27c"
));
cl_assert_equal_oid
(
&
e
.
tree_oid
,
&
id
);
cl_assert_equal_i
(
e
.
generation
,
7
);
cl_assert_equal_i
(
e
.
commit_time
,
1447083009ull
);
cl_assert_equal_i
(
e
.
commit_time
,
UINT64_C
(
1447083009
)
);
cl_assert_equal_i
(
e
.
parent_count
,
3
);
cl_git_pass
(
git_oid_fromstr
(
&
id
,
"ad2ace9e15f66b3d1138922e6ffdc3ea3f967fa6"
));
...
...
tests/revwalk/basic.c
View file @
6a7f0403
...
...
@@ -530,7 +530,7 @@ void test_revwalk_basic__big_timestamp(void)
cl_git_pass
(
git_reference_peel
((
git_object
**
)
&
tip
,
head
,
GIT_OBJECT_COMMIT
));
/* Commit with a far-ahead timestamp, we should be able to parse it in the revwalk */
cl_git_pass
(
git_signature_new
(
&
sig
,
"Joe"
,
"joe@example.com"
,
2399662595ll
,
0
));
cl_git_pass
(
git_signature_new
(
&
sig
,
"Joe"
,
"joe@example.com"
,
INT64_C
(
2399662595
)
,
0
));
cl_git_pass
(
git_commit_tree
(
&
tree
,
tip
));
cl_git_pass
(
git_commit_create
(
&
id
,
_repo
,
"HEAD"
,
sig
,
sig
,
NULL
,
"some message"
,
tree
,
1
,
...
...
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