Skip to content

Commit

Permalink
Remove unused parameters from functions that it is safe to do so in.
Browse files Browse the repository at this point in the history
Every case has been proven to be safe as they were not even used to begin with are not used as callbacks or as part of an API.
  • Loading branch information
RSilicon committed Jul 4, 2023
1 parent 8a6cd08 commit a35f0b3
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 67 deletions.
21 changes: 9 additions & 12 deletions channels.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ channel_set_xtype(struct ssh *ssh, int id, const char *xctype)
* when the channel consumer/producer is ready, e.g. shell exec'd
*/
static void
channel_register_fds(struct ssh *ssh, Channel *c, int rfd, int wfd, int efd,
channel_register_fds(Channel *c, int rfd, int wfd, int efd,
int extusage, int nonblock, int is_tty)
{
int val;
Expand Down Expand Up @@ -488,7 +488,7 @@ channel_new(struct ssh *ssh, char *ctype, int type, int rfd, int wfd, int efd,
fatal_fr(r, "sshbuf_set_max_size");
c->ostate = CHAN_OUTPUT_OPEN;
c->istate = CHAN_INPUT_OPEN;
channel_register_fds(ssh, c, rfd, wfd, efd, extusage, nonblock, 0);
channel_register_fds(c, rfd, wfd, efd, extusage, nonblock, 0);
c->self = found;
c->type = type;
c->ctype = ctype;
Expand Down Expand Up @@ -1178,7 +1178,7 @@ channel_set_fds(struct ssh *ssh, int id, int rfd, int wfd, int efd,
if (!c->have_remote_id)
fatal_f("channel %d: no remote id", c->self);

channel_register_fds(ssh, c, rfd, wfd, efd, extusage, nonblock, is_tty);
channel_register_fds(c, rfd, wfd, efd, extusage, nonblock, is_tty);
c->type = SSH_CHANNEL_OPEN;
c->lastused = monotime();
c->local_window = c->local_window_max = window_max;
Expand Down Expand Up @@ -1650,7 +1650,7 @@ channel_connect_stdio_fwd(struct ssh *ssh,
c->listening_port = 0;
c->force_drain = 1;

channel_register_fds(ssh, c, in, out, -1, 0, 1, 0);
channel_register_fds(c, in, out, -1, 0, 1, 0);
port_open_helper(ssh, c, "direct-tcpip");

return c;
Expand Down Expand Up @@ -4596,7 +4596,7 @@ channel_connect_ctx_free(struct channel_connect *cctx)
*/
static int
connect_to_helper(struct ssh *ssh, const char *name, int port, int socktype,
char *ctype, char *rname, struct channel_connect *cctx,
struct channel_connect *cctx,
int *reason, const char **errmsg)
{
struct addrinfo hints;
Expand Down Expand Up @@ -4669,8 +4669,7 @@ connect_to(struct ssh *ssh, const char *host, int port,
int sock;

memset(&cctx, 0, sizeof(cctx));
sock = connect_to_helper(ssh, host, port, SOCK_STREAM, ctype, rname,
&cctx, NULL, NULL);
sock = connect_to_helper(ssh, host, port, SOCK_STREAM, &cctx, NULL, NULL);
if (sock == -1) {
channel_connect_ctx_free(&cctx);
return NULL;
Expand Down Expand Up @@ -4783,8 +4782,7 @@ channel_connect_to_port(struct ssh *ssh, const char *host, u_short port,
}

memset(&cctx, 0, sizeof(cctx));
sock = connect_to_helper(ssh, host, port, SOCK_STREAM, ctype, rname,
&cctx, reason, errmsg);
sock = connect_to_helper(ssh, host, port, SOCK_STREAM, &cctx, reason, errmsg);
if (sock == -1) {
channel_connect_ctx_free(&cctx);
return NULL;
Expand Down Expand Up @@ -4915,15 +4913,14 @@ rdynamic_connect_finish(struct ssh *ssh, Channel *c)
}

memset(&cctx, 0, sizeof(cctx));
sock = connect_to_helper(ssh, c->path, c->host_port, SOCK_STREAM, NULL,
NULL, &cctx, NULL, NULL);
sock = connect_to_helper(ssh, c->path, c->host_port, SOCK_STREAM, &cctx, NULL, NULL);
if (sock == -1)
channel_connect_ctx_free(&cctx);
else {
/* similar to SSH_CHANNEL_CONNECTING but we've already sent the open */
c->type = SSH_CHANNEL_RDYNAMIC_FINISH;
c->connect_ctx = cctx;
channel_register_fds(ssh, c, sock, sock, -1, 0, 1, 0);
channel_register_fds(c, sock, sock, -1, 0, 1, 0);
}
return sock;
}
Expand Down
4 changes: 2 additions & 2 deletions kex.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ choose_enc(struct sshenc *enc, char *client, char *server)
}

static int
choose_mac(struct ssh *ssh, struct sshmac *mac, char *client, char *server)
choose_mac(struct sshmac *mac, char *client, char *server)
{
char *name = match_list(client, server, NULL);

Expand Down Expand Up @@ -1050,7 +1050,7 @@ kex_choose_conf(struct ssh *ssh)
authlen = cipher_authlen(newkeys->enc.cipher);
/* ignore mac for authenticated encryption */
if (authlen == 0 &&
(r = choose_mac(ssh, &newkeys->mac, cprop[nmac],
(r = choose_mac(&newkeys->mac, cprop[nmac],
sprop[nmac])) != 0) {
kex->failed_choice = peer[nmac];
peer[nmac] = NULL;
Expand Down
4 changes: 2 additions & 2 deletions packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ ssh_packet_read_expect(struct ssh *ssh, u_int expected_type)
}

static int
ssh_packet_read_poll2_mux(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
ssh_packet_read_poll2_mux(struct ssh *ssh, u_char *typep)
{
struct session_state *state = ssh->state;
const u_char *cp;
Expand Down Expand Up @@ -1488,7 +1488,7 @@ ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
int r;

if (state->mux)
return ssh_packet_read_poll2_mux(ssh, typep, seqnr_p);
return ssh_packet_read_poll2_mux(ssh, typep);

*typep = SSH_MSG_NONE;

Expand Down
4 changes: 2 additions & 2 deletions serverloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ process_input(struct ssh *ssh, int connection_in)
* Sends data from internal buffers to client program stdin.
*/
static void
process_output(struct ssh *ssh, int connection_out)
process_output(struct ssh *ssh)
{
int r;

Expand Down Expand Up @@ -397,7 +397,7 @@ server_loop2(struct ssh *ssh, Authctxt *authctxt)
if ((r = ssh_packet_check_rekey(ssh)) != 0)
fatal_fr(r, "cannot start rekeying");
if (conn_out_ready)
process_output(ssh, connection_out);
process_output(ssh);
}
collect_children(ssh);
free(pfd);
Expand Down
12 changes: 6 additions & 6 deletions session.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ prepare_auth_info_file(struct passwd *pw, struct sshbuf *info)
}

static void
set_fwdpermit_from_authopts(struct ssh *ssh, const struct sshauthopt *opts)
set_fwdpermit_from_authopts(struct ssh *ssh)
{
char *tmp, *cp, *host;
int port;
Expand Down Expand Up @@ -338,7 +338,7 @@ do_authenticated(struct ssh *ssh, Authctxt *authctxt)

/* setup the channel layer */
/* XXX - streamlocal? */
set_fwdpermit_from_authopts(ssh, auth_opts);
set_fwdpermit_from_authopts(ssh);

if (!auth_opts->permit_port_forwarding_flag ||
options.disable_forwarding) {
Expand Down Expand Up @@ -1198,7 +1198,7 @@ do_setup_env(struct ssh *ssh, Session *s, const char *shell)
* first in this order).
*/
static void
do_rc_files(struct ssh *ssh, Session *s, const char *shell)
do_rc_files(Session *s, const char *shell)
{
FILE *f = NULL;
char *cmd = NULL, *user_rc = NULL;
Expand Down Expand Up @@ -1304,7 +1304,7 @@ do_nologin(struct passwd *pw)
* must be root-owned directories with strict permissions.
*/
static void
safely_chroot(const char *path, uid_t uid)
safely_chroot(const char *path)
{
const char *cp;
char component[PATH_MAX];
Expand Down Expand Up @@ -1393,7 +1393,7 @@ do_setusercontext(struct passwd *pw)
(unsigned long long)pw->pw_uid);
chroot_path = percent_expand(tmp, "h", pw->pw_dir,
"u", pw->pw_name, "U", uidstr, (char *)NULL);
safely_chroot(chroot_path, pw->pw_uid);
safely_chroot(chroot_path);
free(tmp);
free(chroot_path);
/* Make sure we don't attempt to chroot again */
Expand Down Expand Up @@ -1637,7 +1637,7 @@ do_child(struct ssh *ssh, Session *s, const char *command)

closefrom(STDERR_FILENO + 1);

do_rc_files(ssh, s, shell);
do_rc_files(s, shell);

/* restore SIGPIPE for child */
ssh_signal(SIGPIPE, SIG_DFL);
Expand Down
6 changes: 3 additions & 3 deletions sftp-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ upload_dir(struct sftp_conn *conn, const char *src, const char *dst,
}

static void
handle_dest_replies(struct sftp_conn *to, const char *to_path, int synchronous,
handle_dest_replies(struct sftp_conn *to, int synchronous,
u_int *nreqsp, u_int *write_errorp)
{
struct sshbuf *msg;
Expand Down Expand Up @@ -2517,7 +2517,7 @@ do_crossload(struct sftp_conn *from, struct sftp_conn *to,
}

/* Try to eat replies from the upload side (nonblocking) */
handle_dest_replies(to, to_path, 0,
handle_dest_replies(to, 0,
&num_upload_req, &write_error);

sshbuf_reset(msg);
Expand Down Expand Up @@ -2614,7 +2614,7 @@ do_crossload(struct sftp_conn *from, struct sftp_conn *to,

/* Drain replies from the server (blocking) */
debug3_f("waiting for %u replies from destination", num_upload_req);
handle_dest_replies(to, to_path, 1, &num_upload_req, &write_error);
handle_dest_replies(to, 1, &num_upload_req, &write_error);

/* Sanity check */
if (TAILQ_FIRST(&requests) != NULL)
Expand Down
4 changes: 2 additions & 2 deletions sntrup761.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ static void ZDecrypt(Inputs r,const unsigned char *c,const unsigned char *sk)
#define Confirm_bytes 32

/* h = HashConfirm(r,pk,cache); cache is Hash4(pk) */
static void HashConfirm(unsigned char *h,const unsigned char *r,const unsigned char *pk,const unsigned char *cache)
static void HashConfirm(unsigned char *h,const unsigned char *r,const unsigned char *cache)
{
#ifndef LPR
unsigned char x[Hash_bytes*2];
Expand Down Expand Up @@ -1205,7 +1205,7 @@ static void Hide(unsigned char *c,unsigned char *r_enc,const Inputs r,const unsi
{
Inputs_encode(r_enc,r);
ZEncrypt(c,r,pk); c += Ciphertexts_bytes;
HashConfirm(c,r_enc,pk,cache);
HashConfirm(c,r_enc,cache);
}

/* c,k = Encap(pk) */
Expand Down
39 changes: 17 additions & 22 deletions ssh-keygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ do_print_public(struct passwd *pw)
}

static void
do_download(struct passwd *pw)
do_download(void)
{
#ifdef ENABLE_PKCS11
struct sshkey **keys = NULL;
Expand Down Expand Up @@ -1481,7 +1481,7 @@ do_change_passphrase(struct passwd *pw)
* Print the SSHFP RR.
*/
static int
do_print_resource_record(struct passwd *pw, char *fname, char *hname,
do_print_resource_record(char *fname, char *hname,
int print_generic, char * const *opts, size_t nopts)
{
struct sshkey *public;
Expand Down Expand Up @@ -1709,7 +1709,7 @@ finalise_cert_exts(void)
}

static struct sshkey *
load_pkcs11_key(char *path)
load_pkcs11_key()
{
#ifdef ENABLE_PKCS11
struct sshkey **keys = NULL, *public, *private = NULL;
Expand Down Expand Up @@ -1771,7 +1771,7 @@ do_ca_sign(struct passwd *pw, const char *ca_key_path, int prefer_agent,
tmp = tilde_expand_filename(ca_key_path, pw->pw_uid);
if (pkcs11provider != NULL) {
/* If a PKCS#11 token was specified then try to use it */
if ((ca = load_pkcs11_key(tmp)) == NULL)
if ((ca = load_pkcs11_key()) == NULL)
fatal("No PKCS#11 key matching %s found", ca_key_path);
} else if (prefer_agent) {
/*
Expand Down Expand Up @@ -2471,7 +2471,7 @@ do_gen_krl(struct passwd *pw, int updating, const char *ca_key_path,
}

static void
do_check_krl(struct passwd *pw, int print_krl, int argc, char **argv)
do_check_krl(int print_krl, int argc, char **argv)
{
int i, r, ret = 0;
char *comment;
Expand Down Expand Up @@ -2946,7 +2946,7 @@ sig_match_principals(const char *allowed_keys, char *principal,
}

static void
do_moduli_gen(const char *out_file, char **opts, size_t nopts)
do_moduli_gen(char **opts, size_t nopts)
{
#ifdef WITH_OPENSSL
/* Moduli generation/screening */
Expand Down Expand Up @@ -2999,7 +2999,7 @@ do_moduli_gen(const char *out_file, char **opts, size_t nopts)
}

static void
do_moduli_screen(const char *out_file, char **opts, size_t nopts)
do_moduli_screen(char **opts, size_t nopts)
{
#ifdef WITH_OPENSSL
/* Moduli generation/screening */
Expand Down Expand Up @@ -3690,7 +3690,7 @@ main(int argc, char **argv)
return (0);
}
if (check_krl) {
do_check_krl(pw, print_fingerprint, argc, argv);
do_check_krl(print_fingerprint, argc, argv);
return (0);
}
if (ca_key_path != NULL) {
Expand All @@ -3708,7 +3708,7 @@ main(int argc, char **argv)
delete_host, hash_hosts);
}
if (pkcs11provider != NULL)
do_download(pw);
do_download();
if (download_sk) {
for (i = 0; i < nopts; i++) {
if (strncasecmp(opts[i], "device=", 7) == 0) {
Expand Down Expand Up @@ -3741,27 +3741,22 @@ main(int argc, char **argv)
unsigned int n = 0;

if (have_identity) {
n = do_print_resource_record(pw, identity_file,
n = do_print_resource_record(identity_file,
rr_hostname, print_generic, opts, nopts);
if (n == 0)
fatal("%s: %s", identity_file, strerror(errno));
exit(0);
} else {

n += do_print_resource_record(pw,
_PATH_HOST_RSA_KEY_FILE, rr_hostname,
n += do_print_resource_record(_PATH_HOST_RSA_KEY_FILE, rr_hostname,
print_generic, opts, nopts);
n += do_print_resource_record(pw,
_PATH_HOST_DSA_KEY_FILE, rr_hostname,
n += do_print_resource_record(_PATH_HOST_DSA_KEY_FILE, rr_hostname,
print_generic, opts, nopts);
n += do_print_resource_record(pw,
_PATH_HOST_ECDSA_KEY_FILE, rr_hostname,
n += do_print_resource_record(_PATH_HOST_ECDSA_KEY_FILE, rr_hostname,
print_generic, opts, nopts);
n += do_print_resource_record(pw,
_PATH_HOST_ED25519_KEY_FILE, rr_hostname,
n += do_print_resource_record(_PATH_HOST_ED25519_KEY_FILE, rr_hostname,
print_generic, opts, nopts);
n += do_print_resource_record(pw,
_PATH_HOST_XMSS_KEY_FILE, rr_hostname,
n += do_print_resource_record(_PATH_HOST_XMSS_KEY_FILE, rr_hostname,
print_generic, opts, nopts);
if (n == 0)
fatal("no keys found.");
Expand All @@ -3776,11 +3771,11 @@ main(int argc, char **argv)
fatal("Too many output files specified");
}
if (do_gen_candidates) {
do_moduli_gen(argv[0], opts, nopts);
do_moduli_gen(opts, nopts);
return 0;
}
if (do_screen_candidates) {
do_moduli_screen(argv[0], opts, nopts);
do_moduli_screen(opts, nopts);
return 0;
}

Expand Down
Loading

0 comments on commit a35f0b3

Please sign in to comment.