From c19c638d740d31928601d51e0a87459d35d7adbe Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sat, 17 Sep 2011 10:28:39 +0200 Subject: error: Use macros for error functions. --- include/libssh/priv.h | 29 +++++++++++++------ src/auth.c | 23 ++++++++------- src/bind.c | 2 +- src/channels.c | 28 +++++++++--------- src/error.c | 42 ++++++++++++++++++--------- src/log.c | 24 +++++++++------- src/options.c | 80 +++++++++++++++++++++++++-------------------------- src/sftp.c | 16 +++++------ 8 files changed, 138 insertions(+), 106 deletions(-) diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 2258d5dd..c6e790f3 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -155,9 +155,20 @@ SSH_PACKET_CALLBACK(ssh_packet_service_accept); int ssh_config_parse_file(ssh_session session, const char *filename); /* errors.c */ -void ssh_set_error(void *error, int code, const char *descr, ...) PRINTF_ATTRIBUTE(3, 4); -void ssh_set_error_oom(void *); -void ssh_set_error_invalid(void *, const char *); +#define ssh_set_error(error, code, ...) \ + _ssh_set_error(error, code, __FUNCTION__, __VA_ARGS__) +void _ssh_set_error(void *error, + int code, + const char *function, + const char *descr, ...) PRINTF_ATTRIBUTE(4, 5); + +#define ssh_set_error_oom(error) \ + _ssh_set_error_oom(error, __FUNCTION__) +void _ssh_set_error_oom(void *error, const char *function); + +#define ssh_set_error_invalid(error) \ + _ssh_set_error_invalid(error, __FUNCTION__) +void _ssh_set_error_invalid(void *error, const char *function); /* in crypt.c */ uint32_t packet_decrypt_len(ssh_session session,char *crypted); @@ -210,10 +221,6 @@ uint32_t ssh_crc32(const char *buf, uint32_t len); int match_hostname(const char *host, const char *pattern, unsigned int len); int message_handle(ssh_session session, void *user, uint8_t type, ssh_buffer packet); -/* log.c */ - -void ssh_log_common(struct ssh_common_struct *common, int verbosity, - const char *format, ...) PRINTF_ATTRIBUTE(3, 4); /* misc.c */ #ifdef _WIN32 @@ -260,12 +267,18 @@ SSH_PACKET_CALLBACK(ssh_packet_kexdh_init); /* LOGGING */ #define SSH_LOG(session, priority, ...) \ - _ssh_log(session, priority, __FUNCTION__, __VA_ARGS__) + ssh_log_function(session, priority, __FUNCTION__, __VA_ARGS__) void ssh_log_function(ssh_session session, int prioriry, const char *function, const char *format, ...) PRINTF_ATTRIBUTE(4, 5); +void ssh_log_common(struct ssh_common_struct *common, + int verbosity, + const char *function, + const char *format, ...) PRINTF_ATTRIBUTE(4, 5); + + /** Free memory space */ #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) diff --git a/src/auth.c b/src/auth.c index 8d1acf0d..840a0716 100644 --- a/src/auth.c +++ b/src/auth.c @@ -349,7 +349,8 @@ int ssh_userauth_none(ssh_session session, const char *username) { case SSH_PENDING_CALL_AUTH_NONE: goto pending; default: - ssh_set_error(session,SSH_FATAL,"Bad call during pending SSH call in ssh_userauth_none"); + ssh_set_error(session, SSH_FATAL, + "Wrong state during pending SSH call"); return SSH_AUTH_ERROR; } @@ -485,7 +486,7 @@ int ssh_userauth_try_publickey(ssh_session session, default: ssh_set_error(session, SSH_FATAL, - "Bad call during pending SSH call in ssh_userauth_try_pubkey"); + "Wrong state during pending SSH call"); return SSH_ERROR; } @@ -1296,7 +1297,7 @@ int ssh_userauth_password(ssh_session session, default: ssh_set_error(session, SSH_FATAL, - "Bad call during pending SSH call in ssh_userauth_try_pubkey"); + "Wrong state during pending SSH call"); return SSH_ERROR; } @@ -1513,7 +1514,7 @@ static int ssh_userauth_kbdint_init(ssh_session session, if (session->pending_call_state == SSH_PENDING_CALL_AUTH_KBDINT_INIT) goto pending; if (session->pending_call_state != SSH_PENDING_CALL_NONE){ - ssh_set_error_invalid(session,"ssh_userauth_kbdint_init"); + ssh_set_error_invalid(session); return SSH_ERROR; } rc = ssh_userauth_request_service(session); @@ -1635,7 +1636,7 @@ static int ssh_userauth_kbdint_send(ssh_session session) if (session->pending_call_state == SSH_PENDING_CALL_AUTH_KBDINT_SEND) goto pending; if (session->pending_call_state != SSH_PENDING_CALL_NONE){ - ssh_set_error_invalid(session,"ssh_userauth_kbdint_send"); + ssh_set_error_invalid(session); return SSH_ERROR; } rc = buffer_add_u8(session->out_buffer, SSH2_MSG_USERAUTH_INFO_RESPONSE); @@ -1892,7 +1893,7 @@ int ssh_userauth_kbdint_getnprompts(ssh_session session) { if(session==NULL) return SSH_ERROR; if(session->kbdint == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return SSH_ERROR; } return session->kbdint->nprompts; @@ -1912,7 +1913,7 @@ const char *ssh_userauth_kbdint_getname(ssh_session session) { if(session==NULL) return NULL; if(session->kbdint == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return NULL; } return session->kbdint->name; @@ -1933,7 +1934,7 @@ const char *ssh_userauth_kbdint_getinstruction(ssh_session session) { if(session==NULL) return NULL; if(session->kbdint == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return NULL; } return session->kbdint->instruction; @@ -1960,11 +1961,11 @@ const char *ssh_userauth_kbdint_getprompt(ssh_session session, unsigned int i, if(session==NULL) return NULL; if(session->kbdint == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return NULL; } if (i > session->kbdint->nprompts) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return NULL; } @@ -2031,7 +2032,7 @@ int ssh_userauth_kbdint_setanswer(ssh_session session, unsigned int i, return -1; if (answer == NULL || session->kbdint == NULL || i >= session->kbdint->nprompts) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } diff --git a/src/bind.c b/src/bind.c index 85252ae2..ca8ad6a6 100644 --- a/src/bind.c +++ b/src/bind.c @@ -236,7 +236,7 @@ int ssh_bind_set_callbacks(ssh_bind sshbind, ssh_bind_callbacks callbacks, return SSH_ERROR; } if (callbacks == NULL) { - ssh_set_error_invalid(sshbind, __FUNCTION__); + ssh_set_error_invalid(sshbind); return SSH_ERROR; } if(callbacks->size <= 0 || callbacks->size > 1024 * sizeof(void *)){ diff --git a/src/channels.c b/src/channels.c index 39f29c45..5056ad0a 100644 --- a/src/channels.c +++ b/src/channels.c @@ -851,7 +851,7 @@ int channel_default_bufferize(ssh_channel channel, void *data, int len, session = channel->session; if(data == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -966,7 +966,7 @@ int ssh_channel_open_forward(ssh_channel channel, const char *remotehost, session = channel->session; if(remotehost == NULL || sourcehost == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return rc; } @@ -1213,7 +1213,7 @@ int channel_write_common(ssh_channel channel, const void *data, } session = channel->session; if(data == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -1608,7 +1608,7 @@ int ssh_channel_request_pty_size(ssh_channel channel, const char *terminal, return SSH_ERROR; } if(terminal == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return rc; } @@ -1772,7 +1772,7 @@ int ssh_channel_request_subsystem(ssh_channel channel, const char *subsys) { return SSH_ERROR; } if(subsys == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return rc; } switch(channel->request_state){ @@ -2276,7 +2276,7 @@ int ssh_channel_request_env(ssh_channel channel, const char *name, const char *v return SSH_ERROR; } if(name == NULL || value == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return rc; } switch(channel->request_state){ @@ -2360,7 +2360,7 @@ int ssh_channel_request_exec(ssh_channel channel, const char *cmd) { return SSH_ERROR; } if(cmd == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return rc; } @@ -2441,7 +2441,7 @@ int ssh_channel_request_send_signal(ssh_channel channel, const char *sig) { return SSH_ERROR; } if(sig == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return rc; } @@ -2506,7 +2506,7 @@ int channel_read_buffer(ssh_channel channel, ssh_buffer buffer, uint32_t count, return SSH_ERROR; } if(buffer == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return SSH_ERROR; } @@ -2610,7 +2610,7 @@ int ssh_channel_read(ssh_channel channel, void *dest, uint32_t count, int is_std return SSH_ERROR; } if(dest == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return SSH_ERROR; } @@ -2713,7 +2713,7 @@ int ssh_channel_read_nonblocking(ssh_channel channel, void *dest, uint32_t count return SSH_ERROR; } if(dest == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return SSH_ERROR; } @@ -3146,7 +3146,7 @@ int ssh_channel_open_reverse_forward(ssh_channel channel, const char *remotehost return rc; } if(remotehost == NULL || sourcehost == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return rc; } @@ -3228,7 +3228,7 @@ int ssh_channel_open_x11(ssh_channel channel, return rc; } if(orig_addr == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return rc; } session = channel->session; @@ -3343,7 +3343,7 @@ int ssh_channel_request_send_exit_signal(ssh_channel channel, const char *sig, return rc; } if(sig == NULL || errmsg == NULL || lang == NULL) { - ssh_set_error_invalid(channel->session, __FUNCTION__); + ssh_set_error_invalid(channel->session); return rc; } #ifdef WITH_SSH1 diff --git a/src/error.c b/src/error.c index 46d6382d..f4a2af00 100644 --- a/src/error.c +++ b/src/error.c @@ -48,14 +48,24 @@ * * @param ... The arguments for the format string. */ -void ssh_set_error(void *error, int code, const char *descr, ...) { - struct ssh_common_struct *err = error; - va_list va; - va_start(va, descr); - vsnprintf(err->error.error_buffer, ERROR_BUFFERLEN, descr, va); - va_end(va); - err->error.error_code = code; - ssh_log_common(err,SSH_LOG_RARE,"Error : %s",err->error.error_buffer); +void _ssh_set_error(void *error, + int code, + const char *function, + const char *descr, ...) +{ + struct ssh_common_struct *err = error; + va_list va; + + va_start(va, descr); + vsnprintf(err->error.error_buffer, ERROR_BUFFERLEN, descr, va); + va_end(va); + + err->error.error_code = code; + ssh_log_common(err, + SSH_LOG_WARN, + function, + "Error: %s", + err->error.error_buffer); } /** @@ -66,11 +76,13 @@ void ssh_set_error(void *error, int code, const char *descr, ...) { * @param error The place to store the error. * */ -void ssh_set_error_oom(void *error) { - struct error_struct *err = error; +void _ssh_set_error_oom(void *error, const char *function) +{ + struct error_struct *err = error; - strcpy(err->error_buffer, "Out of memory"); - err->error_code = SSH_FATAL; + snprintf(err->error_buffer, sizeof(err->error_buffer), + "%s: Out of memory", function); + err->error_code = SSH_FATAL; } /** @@ -83,8 +95,10 @@ void ssh_set_error_oom(void *error) { * @param function The function the error happened in. * */ -void ssh_set_error_invalid(void *error, const char *function) { - ssh_set_error(error, SSH_FATAL, "Invalid argument in %s", function); +void _ssh_set_error_invalid(void *error, const char *function) +{ + _ssh_set_error(error, SSH_FATAL, function, + "Invalid argument in %s", function); } /** diff --git a/src/log.c b/src/log.c index 081d83d9..df83b0dd 100644 --- a/src/log.c +++ b/src/log.c @@ -136,16 +136,20 @@ void ssh_log_function(ssh_session session, * @param verbosity The verbosity of the event. * @param format The format string of the log entry. */ -void ssh_log_common(struct ssh_common_struct *common, int verbosity, const char *format, ...){ - char buffer[1024]; - va_list va; - - if (verbosity <= common->log_verbosity) { - va_start(va, format); - vsnprintf(buffer, sizeof(buffer), format, va); - va_end(va); - do_ssh_log(common, verbosity, "common", buffer); - } +void ssh_log_common(struct ssh_common_struct *common, + int verbosity, + const char *function, + const char *format, ...) +{ + char buffer[1024]; + va_list va; + + if (verbosity <= common->log_verbosity) { + va_start(va, format); + vsnprintf(buffer, sizeof(buffer), format, va); + va_end(va); + do_ssh_log(common, verbosity, function, buffer); + } } /** @} */ diff --git a/src/options.c b/src/options.c index 29e3faef..d55a6470 100644 --- a/src/options.c +++ b/src/options.c @@ -380,7 +380,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_HOST: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { q = strdup(value); @@ -415,12 +415,12 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, break; case SSH_OPTIONS_PORT: if (value == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { int *x = (int *) value; if (*x <= 0) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -430,7 +430,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_PORT_STR: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { q = strdup(v); @@ -444,7 +444,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, } SAFE_FREE(q); if (i <= 0) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -454,13 +454,13 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_FD: if (value == NULL) { session->fd = SSH_INVALID_SOCKET; - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { socket_t *x = (socket_t *) value; if (*x < 0) { session->fd = SSH_INVALID_SOCKET; - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -470,7 +470,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_BINDADDR: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -525,7 +525,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_ADD_IDENTITY: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } q = strdup(v); @@ -548,7 +548,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, return -1; } } else if (v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { session->knownhosts = strdup(v); @@ -560,12 +560,12 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, break; case SSH_OPTIONS_TIMEOUT: if (value == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { long *x = (long *) value; if (*x < 0) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -574,12 +574,12 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, break; case SSH_OPTIONS_TIMEOUT_USEC: if (value == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { long *x = (long *) value; if (*x < 0) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -588,12 +588,12 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, break; case SSH_OPTIONS_SSH1: if (value == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { int *x = (int *) value; if (*x < 0) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -602,12 +602,12 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, break; case SSH_OPTIONS_SSH2: if (value == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { int *x = (int *) value; if (*x < 0) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -616,12 +616,12 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, break; case SSH_OPTIONS_LOG_VERBOSITY: if (value == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { int *x = (int *) value; if (*x < 0) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -632,7 +632,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, v = value; if (v == NULL || v[0] == '\0') { session->common.log_verbosity = 0; - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { q = strdup(v); @@ -646,7 +646,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, } SAFE_FREE(q); if (i < 0) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -656,7 +656,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_CIPHERS_C_S: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { if (ssh_options_set_algo(session, SSH_CRYPT_C_S, v) < 0) @@ -666,7 +666,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_CIPHERS_S_C: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { if (ssh_options_set_algo(session, SSH_CRYPT_S_C, v) < 0) @@ -676,7 +676,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_KEY_EXCHANGE: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { if (ssh_options_set_algo(session, SSH_KEX, v) < 0) @@ -686,7 +686,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_COMPRESSION_C_S: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { if (strcasecmp(value,"yes")==0){ @@ -704,7 +704,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_COMPRESSION_S_C: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { if (strcasecmp(value,"yes")==0){ @@ -722,7 +722,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_COMPRESSION: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } if(ssh_options_set(session,SSH_OPTIONS_COMPRESSION_C_S, v) < 0) @@ -732,12 +732,12 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, break; case SSH_OPTIONS_COMPRESSION_LEVEL: if (value == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { int *x = (int *)value; if (*x < 1 || *x > 9) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } session->compressionlevel = *x & 0xff; @@ -745,7 +745,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, break; case SSH_OPTIONS_STRICTHOSTKEYCHECK: if (value == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { int *x = (int *) value; @@ -757,7 +757,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type, case SSH_OPTIONS_PROXYCOMMAND: v = value; if (v == NULL || v[0] == '\0') { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } else { SAFE_FREE(session->ProxyCommand); @@ -977,7 +977,7 @@ int ssh_options_parse_config(ssh_session session, const char *filename) { return -1; } if (session->host == NULL) { - ssh_set_error_invalid(session, __FUNCTION__); + ssh_set_error_invalid(session); return -1; } @@ -1159,7 +1159,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, switch (type) { case SSH_BIND_OPTIONS_HOSTKEY: if (value == NULL) { - ssh_set_error_invalid(sshbind, __FUNCTION__); + ssh_set_error_invalid(sshbind); return -1; } else { if (ssh_bind_options_set_algo(sshbind, SSH_HOSTKEYS, value) < 0) @@ -1168,7 +1168,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, break; case SSH_BIND_OPTIONS_BINDADDR: if (value == NULL) { - ssh_set_error_invalid(sshbind, __FUNCTION__); + ssh_set_error_invalid(sshbind); return -1; } else { SAFE_FREE(sshbind->bindaddr); @@ -1181,7 +1181,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, break; case SSH_BIND_OPTIONS_BINDPORT: if (value == NULL) { - ssh_set_error_invalid(sshbind, __FUNCTION__); + ssh_set_error_invalid(sshbind); return -1; } else { int *x = (int *) value; @@ -1208,7 +1208,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, break; case SSH_BIND_OPTIONS_LOG_VERBOSITY: if (value == NULL) { - ssh_set_error_invalid(sshbind, __FUNCTION__); + ssh_set_error_invalid(sshbind); return -1; } else { int *x = (int *) value; @@ -1235,7 +1235,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, break; case SSH_BIND_OPTIONS_DSAKEY: if (value == NULL) { - ssh_set_error_invalid(sshbind, __FUNCTION__); + ssh_set_error_invalid(sshbind); return -1; } else { SAFE_FREE(sshbind->dsakey); @@ -1248,7 +1248,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, break; case SSH_BIND_OPTIONS_RSAKEY: if (value == NULL) { - ssh_set_error_invalid(sshbind, __FUNCTION__); + ssh_set_error_invalid(sshbind); return -1; } else { SAFE_FREE(sshbind->rsakey); @@ -1261,7 +1261,7 @@ int ssh_bind_options_set(ssh_bind sshbind, enum ssh_bind_options_e type, break; case SSH_BIND_OPTIONS_BANNER: if (value == NULL) { - ssh_set_error_invalid(sshbind, __FUNCTION__); + ssh_set_error_invalid(sshbind); return -1; } else { SAFE_FREE(sshbind->banner); diff --git a/src/sftp.c b/src/sftp.c index 4c249e30..6000a9d8 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -636,12 +636,12 @@ const char *sftp_extensions_get_name(sftp_session sftp, unsigned int idx) { if (sftp == NULL) return NULL; if (sftp->ext == NULL || sftp->ext->name == NULL) { - ssh_set_error_invalid(sftp->session, __FUNCTION__); + ssh_set_error_invalid(sftp->session); return NULL; } if (idx > sftp->ext->count) { - ssh_set_error_invalid(sftp->session, __FUNCTION__); + ssh_set_error_invalid(sftp->session); return NULL; } @@ -652,12 +652,12 @@ const char *sftp_extensions_get_data(sftp_session sftp, unsigned int idx) { if (sftp == NULL) return NULL; if (sftp->ext == NULL || sftp->ext->name == NULL) { - ssh_set_error_invalid(sftp->session, __FUNCTION__); + ssh_set_error_invalid(sftp->session); return NULL; } if (idx > sftp->ext->count) { - ssh_set_error_invalid(sftp->session, __FUNCTION__); + ssh_set_error_invalid(sftp->session); return NULL; } @@ -2549,7 +2549,7 @@ int sftp_symlink(sftp_session sftp, const char *target, const char *dest) { if (sftp == NULL) return -1; if (target == NULL || dest == NULL) { - ssh_set_error_invalid(sftp->session, __FUNCTION__); + ssh_set_error_invalid(sftp->session); return -1; } @@ -2665,7 +2665,7 @@ char *sftp_readlink(sftp_session sftp, const char *path) { if (sftp == NULL) return NULL; if (path == NULL) { - ssh_set_error_invalid(sftp, __FUNCTION__); + ssh_set_error_invalid(sftp); return NULL; } if (sftp->version < 3){ @@ -2843,7 +2843,7 @@ sftp_statvfs_t sftp_statvfs(sftp_session sftp, const char *path) { if (sftp == NULL) return NULL; if (path == NULL) { - ssh_set_error_invalid(sftp->session, __FUNCTION__); + ssh_set_error_invalid(sftp->session); return NULL; } if (sftp->version < 3){ @@ -3023,7 +3023,7 @@ char *sftp_canonicalize_path(sftp_session sftp, const char *path) { if (sftp == NULL) return NULL; if (path == NULL) { - ssh_set_error_invalid(sftp->session, __FUNCTION__); + ssh_set_error_invalid(sftp->session); return NULL; } -- cgit v1.2.3