Skip to content

Commit 35321e7

Browse files
committed
Improve type stability regarding err variable
1 parent 98cd6bb commit 35321e7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

base/libgit2/callbacks.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,9 @@ function authenticate_ssh(creds::SSHCredentials, libgit2credptr::Ptr{Ptr{Void}},
130130
isusedcreds && return Cint(Error.EAUTH)
131131
end
132132

133-
err = ccall((:git_cred_ssh_key_new, :libgit2), Cint,
133+
return ccall((:git_cred_ssh_key_new, :libgit2), Cint,
134134
(Ptr{Ptr{Void}}, Cstring, Cstring, Cstring, Cstring),
135135
libgit2credptr, creds.user, creds.pubkey, creds.prvkey, creds.pass)
136-
return err
137136
end
138137

139138
function authenticate_userpass(creds::UserPasswordCredentials, libgit2credptr::Ptr{Ptr{Void}},
@@ -164,10 +163,9 @@ function authenticate_userpass(creds::UserPasswordCredentials, libgit2credptr::P
164163
isusedcreds && return Cint(Error.EAUTH)
165164
end
166165

167-
err = ccall((:git_cred_userpass_plaintext_new, :libgit2), Cint,
166+
return ccall((:git_cred_userpass_plaintext_new, :libgit2), Cint,
168167
(Ptr{Ptr{Void}}, Cstring, Cstring),
169168
libgit2credptr, creds.user, creds.pass)
170-
err == 0 && return Cint(0)
171169
end
172170

173171

@@ -200,7 +198,7 @@ counting strategy that prevents repeated usage of faulty credentials.
200198
function credentials_callback(libgit2credptr::Ptr{Ptr{Void}}, url_ptr::Cstring,
201199
username_ptr::Cstring,
202200
allowed_types::Cuint, payload_ptr::Ptr{Void})
203-
err = 0
201+
err = Cint(0)
204202
url = unsafe_string(url_ptr)
205203

206204
# parse url for schema and host
@@ -246,7 +244,7 @@ function credentials_callback(libgit2credptr::Ptr{Ptr{Void}}, url_ptr::Cstring,
246244
end
247245
err = Cint(Error.EAUTH)
248246
end
249-
return Cint(err)
247+
return err
250248
end
251249

252250
function fetchhead_foreach_callback(ref_name::Cstring, remote_url::Cstring,

0 commit comments

Comments
 (0)