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
07a3c992
Commit
07a3c992
authored
Nov 21, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
streams: use GIT_ASSERT
parent
3ff56dae
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
18 deletions
+34
-18
src/streams/mbedtls.c
+6
-4
src/streams/openssl.c
+8
-4
src/streams/registry.c
+3
-3
src/streams/socket.c
+6
-2
src/streams/stransport.c
+6
-3
src/streams/tls.c
+5
-2
No files found.
src/streams/mbedtls.c
View file @
07a3c992
...
@@ -181,8 +181,8 @@ static int ssl_set_error(mbedtls_ssl_context *ssl, int error)
...
@@ -181,8 +181,8 @@ static int ssl_set_error(mbedtls_ssl_context *ssl, int error)
char
errbuf
[
512
];
char
errbuf
[
512
];
int
ret
=
-
1
;
int
ret
=
-
1
;
assert
(
error
!=
MBEDTLS_ERR_SSL_WANT_READ
);
GIT_ASSERT
(
error
!=
MBEDTLS_ERR_SSL_WANT_READ
);
assert
(
error
!=
MBEDTLS_ERR_SSL_WANT_WRITE
);
GIT_ASSERT
(
error
!=
MBEDTLS_ERR_SSL_WANT_WRITE
);
if
(
error
!=
0
)
if
(
error
!=
0
)
mbedtls_strerror
(
error
,
errbuf
,
512
);
mbedtls_strerror
(
error
,
errbuf
,
512
);
...
@@ -423,7 +423,9 @@ int git_mbedtls_stream_new(
...
@@ -423,7 +423,9 @@ int git_mbedtls_stream_new(
git_stream
*
stream
;
git_stream
*
stream
;
int
error
;
int
error
;
assert
(
out
&&
host
&&
port
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
host
);
GIT_ASSERT_ARG
(
port
);
if
((
error
=
git_socket_stream_new
(
&
stream
,
host
,
port
))
<
0
)
if
((
error
=
git_socket_stream_new
(
&
stream
,
host
,
port
))
<
0
)
return
error
;
return
error
;
...
@@ -442,7 +444,7 @@ int git_mbedtls__set_cert_location(const char *path, int is_dir)
...
@@ -442,7 +444,7 @@ int git_mbedtls__set_cert_location(const char *path, int is_dir)
char
errbuf
[
512
];
char
errbuf
[
512
];
mbedtls_x509_crt
*
cacert
;
mbedtls_x509_crt
*
cacert
;
assert
(
path
!=
NULL
);
GIT_ASSERT_ARG
(
path
);
cacert
=
git__malloc
(
sizeof
(
mbedtls_x509_crt
));
cacert
=
git__malloc
(
sizeof
(
mbedtls_x509_crt
));
GIT_ERROR_CHECK_ALLOC
(
cacert
);
GIT_ERROR_CHECK_ALLOC
(
cacert
);
...
...
src/streams/openssl.c
View file @
07a3c992
...
@@ -414,8 +414,8 @@ static int ssl_set_error(SSL *ssl, int error)
...
@@ -414,8 +414,8 @@ static int ssl_set_error(SSL *ssl, int error)
err
=
SSL_get_error
(
ssl
,
error
);
err
=
SSL_get_error
(
ssl
,
error
);
assert
(
err
!=
SSL_ERROR_WANT_READ
);
GIT_ASSERT
(
err
!=
SSL_ERROR_WANT_READ
);
assert
(
err
!=
SSL_ERROR_WANT_WRITE
);
GIT_ASSERT
(
err
!=
SSL_ERROR_WANT_WRITE
);
switch
(
err
)
{
switch
(
err
)
{
case
SSL_ERROR_WANT_CONNECT
:
case
SSL_ERROR_WANT_CONNECT
:
...
@@ -757,7 +757,9 @@ static int openssl_stream_wrap(
...
@@ -757,7 +757,9 @@ static int openssl_stream_wrap(
{
{
openssl_stream
*
st
;
openssl_stream
*
st
;
assert
(
out
&&
in
&&
host
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
in
);
GIT_ASSERT_ARG
(
host
);
st
=
git__calloc
(
1
,
sizeof
(
openssl_stream
));
st
=
git__calloc
(
1
,
sizeof
(
openssl_stream
));
GIT_ERROR_CHECK_ALLOC
(
st
);
GIT_ERROR_CHECK_ALLOC
(
st
);
...
@@ -800,7 +802,9 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
...
@@ -800,7 +802,9 @@ int git_openssl_stream_new(git_stream **out, const char *host, const char *port)
git_stream
*
stream
=
NULL
;
git_stream
*
stream
=
NULL
;
int
error
;
int
error
;
assert
(
out
&&
host
&&
port
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
host
);
GIT_ASSERT_ARG
(
port
);
if
((
error
=
git_socket_stream_new
(
&
stream
,
host
,
port
))
<
0
)
if
((
error
=
git_socket_stream_new
(
&
stream
,
host
,
port
))
<
0
)
return
error
;
return
error
;
...
...
src/streams/registry.c
View file @
07a3c992
...
@@ -51,7 +51,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
...
@@ -51,7 +51,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
git_stream_registration
*
target
;
git_stream_registration
*
target
;
int
error
=
GIT_ENOTFOUND
;
int
error
=
GIT_ENOTFOUND
;
assert
(
out
);
GIT_ASSERT_ARG
(
out
);
switch
(
type
)
{
switch
(
type
)
{
case
GIT_STREAM_STANDARD
:
case
GIT_STREAM_STANDARD
:
...
@@ -61,7 +61,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
...
@@ -61,7 +61,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
target
=
&
stream_registry
.
tls_callbacks
;
target
=
&
stream_registry
.
tls_callbacks
;
break
;
break
;
default
:
default
:
assert
(
0
);
git_error_set
(
GIT_ERROR_INVALID
,
"invalid stream type"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -81,7 +81,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
...
@@ -81,7 +81,7 @@ int git_stream_registry_lookup(git_stream_registration *out, git_stream_t type)
int
git_stream_register
(
git_stream_t
type
,
git_stream_registration
*
registration
)
int
git_stream_register
(
git_stream_t
type
,
git_stream_registration
*
registration
)
{
{
assert
(
!
registration
||
registration
->
init
);
GIT_ASSERT
(
!
registration
||
registration
->
init
);
GIT_ERROR_CHECK_VERSION
(
registration
,
GIT_STREAM_VERSION
,
"stream_registration"
);
GIT_ERROR_CHECK_VERSION
(
registration
,
GIT_STREAM_VERSION
,
"stream_registration"
);
...
...
src/streams/socket.c
View file @
07a3c992
...
@@ -183,7 +183,9 @@ static int default_socket_stream_new(
...
@@ -183,7 +183,9 @@ static int default_socket_stream_new(
{
{
git_socket_stream
*
st
;
git_socket_stream
*
st
;
assert
(
out
&&
host
&&
port
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
host
);
GIT_ASSERT_ARG
(
port
);
st
=
git__calloc
(
1
,
sizeof
(
git_socket_stream
));
st
=
git__calloc
(
1
,
sizeof
(
git_socket_stream
));
GIT_ERROR_CHECK_ALLOC
(
st
);
GIT_ERROR_CHECK_ALLOC
(
st
);
...
@@ -217,7 +219,9 @@ int git_socket_stream_new(
...
@@ -217,7 +219,9 @@ int git_socket_stream_new(
git_stream_registration
custom
=
{
0
};
git_stream_registration
custom
=
{
0
};
int
error
;
int
error
;
assert
(
out
&&
host
&&
port
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
host
);
GIT_ASSERT_ARG
(
port
);
if
((
error
=
git_stream_registry_lookup
(
&
custom
,
GIT_STREAM_STANDARD
))
==
0
)
if
((
error
=
git_stream_registry_lookup
(
&
custom
,
GIT_STREAM_STANDARD
))
==
0
)
init
=
custom
.
init
;
init
=
custom
.
init
;
...
...
src/streams/stransport.c
View file @
07a3c992
...
@@ -167,7 +167,7 @@ static ssize_t stransport_write(git_stream *stream, const char *data, size_t len
...
@@ -167,7 +167,7 @@ static ssize_t stransport_write(git_stream *stream, const char *data, size_t len
if
((
ret
=
SSLWrite
(
st
->
ctx
,
data
,
data_len
,
&
processed
))
!=
noErr
)
if
((
ret
=
SSLWrite
(
st
->
ctx
,
data
,
data_len
,
&
processed
))
!=
noErr
)
return
stransport_error
(
ret
);
return
stransport_error
(
ret
);
assert
(
processed
<
SSIZE_MAX
);
GIT_ASSERT
(
processed
<
SSIZE_MAX
);
return
(
ssize_t
)
processed
;
return
(
ssize_t
)
processed
;
}
}
...
@@ -251,7 +251,9 @@ static int stransport_wrap(
...
@@ -251,7 +251,9 @@ static int stransport_wrap(
stransport_stream
*
st
;
stransport_stream
*
st
;
OSStatus
ret
;
OSStatus
ret
;
assert
(
out
&&
in
&&
host
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
in
);
GIT_ASSERT_ARG
(
host
);
st
=
git__calloc
(
1
,
sizeof
(
stransport_stream
));
st
=
git__calloc
(
1
,
sizeof
(
stransport_stream
));
GIT_ERROR_CHECK_ALLOC
(
st
);
GIT_ERROR_CHECK_ALLOC
(
st
);
...
@@ -305,7 +307,8 @@ int git_stransport_stream_new(git_stream **out, const char *host, const char *po
...
@@ -305,7 +307,8 @@ int git_stransport_stream_new(git_stream **out, const char *host, const char *po
git_stream
*
stream
=
NULL
;
git_stream
*
stream
=
NULL
;
int
error
;
int
error
;
assert
(
out
&&
host
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
host
);
error
=
git_socket_stream_new
(
&
stream
,
host
,
port
);
error
=
git_socket_stream_new
(
&
stream
,
host
,
port
);
...
...
src/streams/tls.c
View file @
07a3c992
...
@@ -20,7 +20,9 @@ int git_tls_stream_new(git_stream **out, const char *host, const char *port)
...
@@ -20,7 +20,9 @@ int git_tls_stream_new(git_stream **out, const char *host, const char *port)
git_stream_registration
custom
=
{
0
};
git_stream_registration
custom
=
{
0
};
int
error
;
int
error
;
assert
(
out
&&
host
&&
port
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
host
);
GIT_ASSERT_ARG
(
port
);
if
((
error
=
git_stream_registry_lookup
(
&
custom
,
GIT_STREAM_TLS
))
==
0
)
{
if
((
error
=
git_stream_registry_lookup
(
&
custom
,
GIT_STREAM_TLS
))
==
0
)
{
init
=
custom
.
init
;
init
=
custom
.
init
;
...
@@ -49,7 +51,8 @@ int git_tls_stream_wrap(git_stream **out, git_stream *in, const char *host)
...
@@ -49,7 +51,8 @@ int git_tls_stream_wrap(git_stream **out, git_stream *in, const char *host)
int
(
*
wrap
)(
git_stream
**
,
git_stream
*
,
const
char
*
)
=
NULL
;
int
(
*
wrap
)(
git_stream
**
,
git_stream
*
,
const
char
*
)
=
NULL
;
git_stream_registration
custom
=
{
0
};
git_stream_registration
custom
=
{
0
};
assert
(
out
&&
in
);
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
in
);
if
(
git_stream_registry_lookup
(
&
custom
,
GIT_STREAM_TLS
)
==
0
)
{
if
(
git_stream_registry_lookup
(
&
custom
,
GIT_STREAM_TLS
)
==
0
)
{
wrap
=
custom
.
wrap
;
wrap
=
custom
.
wrap
;
...
...
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