mirror of
https://github.com/libssh2/libssh2.git
synced 2026-10-24 03:48:58 +03:00
src: improve MSVC C4701 warning fix
Simplify the code to avoid this warning. This might also help avoiding
it with other compilers (e.g. gcc?).
Improves 02f2700a61 #876
Might fix #1083
Closes #1086
This commit is contained in:
12
src/kex.c
12
src/kex.c
@@ -1685,7 +1685,6 @@ do { \
|
||||
static int
|
||||
kex_session_ecdh_curve_type(const char *name, libssh2_curve_type *out_type)
|
||||
{
|
||||
int ret = 0;
|
||||
libssh2_curve_type type;
|
||||
|
||||
if(!name)
|
||||
@@ -1698,19 +1697,14 @@ kex_session_ecdh_curve_type(const char *name, libssh2_curve_type *out_type)
|
||||
else if(strcmp(name, "ecdh-sha2-nistp521") == 0)
|
||||
type = LIBSSH2_EC_CURVE_NISTP521;
|
||||
else {
|
||||
/* silence:
|
||||
warning C4701: potentially uninitialized local variable 'type' used */
|
||||
#if defined(_MSC_VER)
|
||||
type = (libssh2_curve_type)0;
|
||||
#endif
|
||||
ret = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ret == 0 && out_type) {
|
||||
if(out_type) {
|
||||
*out_type = type;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -355,7 +355,6 @@ int
|
||||
_libssh2_ecdsa_curve_type_from_name(const char *name,
|
||||
libssh2_curve_type *out_type)
|
||||
{
|
||||
int ret = 0;
|
||||
libssh2_curve_type type;
|
||||
|
||||
if(!name || strlen(name) != 19)
|
||||
@@ -368,19 +367,14 @@ _libssh2_ecdsa_curve_type_from_name(const char *name,
|
||||
else if(strcmp(name, "ecdsa-sha2-nistp521") == 0)
|
||||
type = LIBSSH2_EC_CURVE_NISTP521;
|
||||
else {
|
||||
/* silence:
|
||||
warning C4701: potentially uninitialized local variable 'type' used */
|
||||
#if defined(_MSC_VER)
|
||||
type = (libssh2_curve_type)0;
|
||||
#endif
|
||||
ret = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ret == 0 && out_type) {
|
||||
if(out_type) {
|
||||
*out_type = type;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* _libssh2_ecdsa_curve_name_with_octal_new
|
||||
|
||||
Reference in New Issue
Block a user