1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 14:39:24 -05:00

Remove some redundant variables and assignments.

This fixes a batch of clang-analyzer warnings of the form 'you
declared / assigned this variable and then never use it'. It doesn't
fix _all_ of them - some are there so that when I add code in the
future _it_ can use the variable without me having to remember to
start setting it - but these are the ones I thought it would make the
code better instead of worse to fix.
This commit is contained in:
Simon Tatham 2018-12-01 14:06:44 +00:00
parent d2ff948207
commit b54147de4b
9 changed files with 19 additions and 29 deletions

View File

@ -2671,7 +2671,7 @@ void setup_config_box(struct controlbox *b, bool midsession,
"Terminal modes"); "Terminal modes");
td = (struct ttymodes_data *) td = (struct ttymodes_data *)
ctrl_alloc(b, sizeof(struct ttymodes_data)); ctrl_alloc(b, sizeof(struct ttymodes_data));
c = ctrl_text(s, "Terminal modes to send:", HELPCTX(ssh_ttymodes)); ctrl_text(s, "Terminal modes to send:", HELPCTX(ssh_ttymodes));
td->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT, td->listbox = ctrl_listbox(s, NULL, NO_SHORTCUT,
HELPCTX(ssh_ttymodes), HELPCTX(ssh_ttymodes),
ttymodes_handler, P(td)); ttymodes_handler, P(td));

View File

@ -1520,20 +1520,18 @@ static void aes_encrypt_cbc_ni(unsigned char *blk, int len, AESContext * ctx)
FUNC_ISA FUNC_ISA
static void aes_decrypt_cbc_ni(unsigned char *blk, int len, AESContext * ctx) static void aes_decrypt_cbc_ni(unsigned char *blk, int len, AESContext * ctx)
{ {
__m128i dec = _mm_setzero_si128();
__m128i last, iv;
__m128i* block = (__m128i*)blk; __m128i* block = (__m128i*)blk;
const __m128i* finish = (__m128i*)(blk + len); const __m128i* finish = (__m128i*)(blk + len);
assert((len & 15) == 0); assert((len & 15) == 0);
/* Load IV */ /* Load IV */
iv = _mm_loadu_si128((__m128i*)(ctx->iv)); __m128i iv = _mm_loadu_si128((__m128i*)(ctx->iv));
while (block < finish) { while (block < finish) {
/* Key schedule ptr */ /* Key schedule ptr */
__m128i* keysched = (__m128i*)ctx->invkeysched; __m128i* keysched = (__m128i*)ctx->invkeysched;
last = _mm_loadu_si128(block); __m128i last = _mm_loadu_si128(block);
dec = _mm_xor_si128(last, *keysched); __m128i dec = _mm_xor_si128(last, *keysched);
switch (ctx->Nr) { switch (ctx->Nr) {
case 14: case 14:
dec = _mm_aesdec_si128(dec, *(++keysched)); dec = _mm_aesdec_si128(dec, *(++keysched));

View File

@ -639,13 +639,10 @@ void search234_step(search234_state *state, int direction)
assert(direction); assert(direction);
assert(node); assert(node);
if (direction > 0) { if (direction > 0)
state->_lo = state->_last + 1; state->_lo = state->_last + 1;
direction = +1; else
} else {
state->_hi = state->_last - 1; state->_hi = state->_last - 1;
direction = -1;
}
if (state->_lo > state->_hi) { if (state->_lo > state->_hi) {
/* /*

View File

@ -735,13 +735,10 @@ static void columns_alloc_horiz(Columns *cols, gint ourwidth,
ColumnsChild *child; ColumnsChild *child;
GList *children; GList *children;
gint i, ncols, colspan, border, *colxpos, childwidth; gint i, ncols, colspan, border, *colxpos, childwidth;
const gint *percentages;
static const gint onecol[] = { 100 };
border = gtk_container_get_border_width(GTK_CONTAINER(cols)); border = gtk_container_get_border_width(GTK_CONTAINER(cols));
ncols = 1; ncols = 1;
percentages = onecol;
/* colxpos gives the starting x position of each column. /* colxpos gives the starting x position of each column.
* We supply n+1 of them, so that we can find the RH edge easily. * We supply n+1 of them, so that we can find the RH edge easily.
* All ending x positions are expected to be adjusted afterwards by * All ending x positions are expected to be adjusted afterwards by
@ -759,12 +756,11 @@ static void columns_alloc_horiz(Columns *cols, gint ourwidth,
/* Column reconfiguration. */ /* Column reconfiguration. */
ncols = child->ncols; ncols = child->ncols;
percentages = child->percentages;
colxpos = g_renew(gint, colxpos, ncols + 1); colxpos = g_renew(gint, colxpos, ncols + 1);
colxpos[0] = 0; colxpos[0] = 0;
percent = 0; percent = 0;
for (i = 0; i < ncols; i++) { for (i = 0; i < ncols; i++) {
percent += percentages[i]; percent += child->percentages[i];
colxpos[i+1] = (((ourwidth - 2*border) + cols->spacing) colxpos[i+1] = (((ourwidth - 2*border) + cols->spacing)
* percent / 100); * percent / 100);
} }

View File

@ -794,7 +794,6 @@ Socket *sk_new(SockAddr *addr, int port, bool privport, bool oobinline,
ret->privport = privport; ret->privport = privport;
ret->port = port; ret->port = port;
err = 0;
do { do {
err = try_connect(ret); err = try_connect(ret);
} while (err && sk_nextaddr(ret->addr, &ret->step)); } while (err && sk_nextaddr(ret->addr, &ret->step));

View File

@ -734,14 +734,14 @@ void run_agent(void)
unsigned long now; unsigned long now;
int *fdlist; int *fdlist;
int fd; int fd;
int i, fdcount, fdsize, fdstate; int i, fdsize, fdstate;
int termination_pid = -1; int termination_pid = -1;
bool errors = false; bool errors = false;
Conf *conf; Conf *conf;
const struct cmdline_key_action *act; const struct cmdline_key_action *act;
fdlist = NULL; fdlist = NULL;
fdcount = fdsize = 0; fdsize = 0;
pageant_init(); pageant_init();
@ -891,7 +891,7 @@ void run_agent(void)
* Add all currently open fds to the select sets, and store * Add all currently open fds to the select sets, and store
* them in fdlist as well. * them in fdlist as well.
*/ */
fdcount = 0; int fdcount = 0;
for (fd = first_fd(&fdstate, &rwx); fd >= 0; for (fd = first_fd(&fdstate, &rwx); fd >= 0;
fd = next_fd(&fdstate, &rwx)) { fd = next_fd(&fdstate, &rwx)) {
fdlist[fdcount++] = fd; fdlist[fdcount++] = fd;

View File

@ -561,7 +561,7 @@ int main(int argc, char **argv)
bool sending; bool sending;
int *fdlist; int *fdlist;
int fd; int fd;
int i, fdcount, fdsize, fdstate; int i, fdsize, fdstate;
int exitcode; int exitcode;
bool errors; bool errors;
bool use_subsystem = false; bool use_subsystem = false;
@ -571,7 +571,7 @@ int main(int argc, char **argv)
const struct BackendVtable *backvt; const struct BackendVtable *backvt;
fdlist = NULL; fdlist = NULL;
fdcount = fdsize = 0; fdsize = 0;
/* /*
* Initialise port and protocol to sensible defaults. (These * Initialise port and protocol to sensible defaults. (These
* will be overridden by more or less anything.) * will be overridden by more or less anything.)
@ -878,7 +878,7 @@ int main(int argc, char **argv)
* Add all currently open fds to the select sets, and store * Add all currently open fds to the select sets, and store
* them in fdlist as well. * them in fdlist as well.
*/ */
fdcount = 0; int fdcount = 0;
for (fd = first_fd(&fdstate, &rwx); fd >= 0; for (fd = first_fd(&fdstate, &rwx); fd >= 0;
fd = next_fd(&fdstate, &rwx)) { fd = next_fd(&fdstate, &rwx)) {
fdlist[fdcount++] = fd; fdlist[fdcount++] = fd;

View File

@ -359,7 +359,7 @@ int main(int argc, char **argv)
{ {
int *fdlist; int *fdlist;
int fd; int fd;
int i, fdcount, fdsize, fdstate; int i, fdsize, fdstate;
unsigned long now; unsigned long now;
ssh_key **hostkeys = NULL; ssh_key **hostkeys = NULL;
@ -531,7 +531,7 @@ int main(int argc, char **argv)
} }
fdlist = NULL; fdlist = NULL;
fdcount = fdsize = 0; fdsize = 0;
random_ref(); random_ref();
@ -580,7 +580,7 @@ int main(int argc, char **argv)
* Add all currently open fds to the select sets, and store * Add all currently open fds to the select sets, and store
* them in fdlist as well. * them in fdlist as well.
*/ */
fdcount = 0; int fdcount = 0;
for (fd = first_fd(&fdstate, &rwx); fd >= 0; for (fd = first_fd(&fdstate, &rwx); fd >= 0;
fd = next_fd(&fdstate, &rwx)) { fd = next_fd(&fdstate, &rwx)) {
fdlist[fdcount++] = fd; fdlist[fdcount++] = fd;

View File

@ -445,14 +445,14 @@ char *dir_file_cat(const char *dir, const char *file)
static int ssh_sftp_do_select(bool include_stdin, bool no_fds_ok) static int ssh_sftp_do_select(bool include_stdin, bool no_fds_ok)
{ {
fd_set rset, wset, xset; fd_set rset, wset, xset;
int i, fdcount, fdsize, *fdlist; int i, fdsize, *fdlist;
int fd, fdstate, rwx, ret, maxfd; int fd, fdcount, fdstate, rwx, ret, maxfd;
unsigned long now = GETTICKCOUNT(); unsigned long now = GETTICKCOUNT();
unsigned long next; unsigned long next;
bool done_something = false; bool done_something = false;
fdlist = NULL; fdlist = NULL;
fdcount = fdsize = 0; fdsize = 0;
do { do {