1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

Placate gcc's `-Wall' warnings.

[originally from svn r1121]
This commit is contained in:
Simon Tatham 2001-05-13 14:02:28 +00:00
parent 93e27a40ae
commit fb473cc16c
14 changed files with 79 additions and 71 deletions

View File

@ -294,8 +294,8 @@ static void keylist_update(void)
static void add_keyfile(char *filename) static void add_keyfile(char *filename)
{ {
char passphrase[PASSPHRASE_MAXLEN]; char passphrase[PASSPHRASE_MAXLEN];
struct RSAKey *rkey; struct RSAKey *rkey = NULL;
struct ssh2_userkey *skey; struct ssh2_userkey *skey = NULL;
int needs_pass; int needs_pass;
int ret; int ret;
int attempts; int attempts;
@ -358,6 +358,7 @@ static void add_keyfile(char *filename)
if (ver == 1) { if (ver == 1) {
if (already_running) { if (already_running) {
unsigned char *request, *response; unsigned char *request, *response;
void *vresponse;
int reqlen, clen, resplen; int reqlen, clen, resplen;
clen = strlen(rkey->comment); clen = strlen(rkey->comment);
@ -391,7 +392,8 @@ static void add_keyfile(char *filename)
reqlen += 4 + clen; reqlen += 4 + clen;
PUT_32BIT(request, reqlen - 4); PUT_32BIT(request, reqlen - 4);
agent_query(request, reqlen, &response, &resplen); agent_query(request, reqlen, &vresponse, &resplen);
response = vresponse;
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS) if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS)
MessageBox(NULL, "The already running Pageant " MessageBox(NULL, "The already running Pageant "
"refused to add the key.", APPNAME, "refused to add the key.", APPNAME,
@ -403,6 +405,7 @@ static void add_keyfile(char *filename)
} else { } else {
if (already_running) { if (already_running) {
unsigned char *request, *response; unsigned char *request, *response;
void *vresponse;
int reqlen, alglen, clen, keybloblen, resplen; int reqlen, alglen, clen, keybloblen, resplen;
alglen = strlen(skey->alg->name); alglen = strlen(skey->alg->name);
clen = strlen(skey->comment); clen = strlen(skey->comment);
@ -431,7 +434,8 @@ static void add_keyfile(char *filename)
PUT_32BIT(request, reqlen - 4); PUT_32BIT(request, reqlen - 4);
reqlen += clen + 4; reqlen += clen + 4;
agent_query(request, reqlen, &response, &resplen); agent_query(request, reqlen, &vresponse, &resplen);
response = vresponse;
if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS) if (resplen < 5 || response[4] != SSH_AGENT_SUCCESS)
MessageBox(NULL, "The already running Pageant" MessageBox(NULL, "The already running Pageant"
"refused to add the key.", APPNAME, "refused to add the key.", APPNAME,
@ -938,11 +942,6 @@ static int cmpkeys_ssh2_asymm(void *av, void *bv)
return c; return c;
} }
static void error(char *s)
{
MessageBox(hwnd, s, APPNAME, MB_OK | MB_ICONERROR);
}
/* /*
* Prompt for a key file to add, and add it. * Prompt for a key file to add, and add it.
*/ */
@ -1135,9 +1134,12 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
COPYDATASTRUCT *cds; COPYDATASTRUCT *cds;
char *mapname; char *mapname;
void *p; void *p;
HANDLE filemap, proc; HANDLE filemap;
#ifndef NO_SECURITY
HANDLE proc;
PSID mapowner, procowner; PSID mapowner, procowner;
PSECURITY_DESCRIPTOR psd1 = NULL, psd2 = NULL; PSECURITY_DESCRIPTOR psd1 = NULL, psd2 = NULL;
#endif
int ret = 0; int ret = 0;
cds = (COPYDATASTRUCT *) lParam; cds = (COPYDATASTRUCT *) lParam;
@ -1154,8 +1156,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
debug(("filemap is %p\n", filemap)); debug(("filemap is %p\n", filemap));
#endif #endif
if (filemap != NULL && filemap != INVALID_HANDLE_VALUE) { if (filemap != NULL && filemap != INVALID_HANDLE_VALUE) {
int rc;
#ifndef NO_SECURITY #ifndef NO_SECURITY
int rc;
if (has_security) { if (has_security) {
if ((proc = OpenProcess(MAXIMUM_ALLOWED, FALSE, if ((proc = OpenProcess(MAXIMUM_ALLOWED, FALSE,
GetCurrentProcessId())) == GetCurrentProcessId())) ==
@ -1234,7 +1236,7 @@ void spawn_cmd(char *cmdline, int show)
NULL, NULL, show) <= (HINSTANCE) 32) { NULL, NULL, show) <= (HINSTANCE) 32) {
TCHAR sMsg[140]; TCHAR sMsg[140];
sprintf(sMsg, _T("Failed to run \"%.100s\", Error: %d"), cmdline, sprintf(sMsg, _T("Failed to run \"%.100s\", Error: %d"), cmdline,
GetLastError()); (int)GetLastError());
MessageBox(NULL, sMsg, APPNAME, MB_OK | MB_ICONEXCLAMATION); MessageBox(NULL, sMsg, APPNAME, MB_OK | MB_ICONEXCLAMATION);
} }
} }
@ -1367,7 +1369,6 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{ {
char *p; char *p;
int inquotes = 0; int inquotes = 0;
int ignorearg = 0;
p = cmdline; p = cmdline;
while (*p) { while (*p) {
while (*p && isspace(*p)) while (*p && isspace(*p))

View File

@ -49,7 +49,7 @@ void agent_query(void *in, int inlen, void **out, int *outlen)
debug(("hwnd is %p\n", hwnd)); debug(("hwnd is %p\n", hwnd));
if (!hwnd) if (!hwnd)
return; return;
sprintf(mapname, "PageantRequest%08x", GetCurrentThreadId()); sprintf(mapname, "PageantRequest%08x", (unsigned)GetCurrentThreadId());
filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, filemap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
0, AGENT_MAX_MSGLEN, mapname); 0, AGENT_MAX_MSGLEN, mapname);
if (!filemap) if (!filemap)

View File

@ -77,6 +77,13 @@ static void progress_update(void *param, int phase, int iprogress)
case 3: case 3:
position = PHASE3START + progress * p->phase3mult; position = PHASE3START + progress * p->phase3mult;
break; break;
default:
/*
* Shouldn't happen, but having a default clause placates
* gcc -Wall, which would otherwise complain that
* `position' might be used uninitialised.
*/
return;
} }
SendMessage(p->progbar, PBM_SETPOS, position / DIVISOR, 0); SendMessage(p->progbar, PBM_SETPOS, position / DIVISOR, 0);
@ -687,7 +694,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
char *comment; char *comment;
struct PassphraseProcStruct pps; struct PassphraseProcStruct pps;
struct RSAKey newkey1; struct RSAKey newkey1;
struct ssh2_userkey *newkey2; struct ssh2_userkey *newkey2 = NULL;
ver = keyfile_version(filename); ver = keyfile_version(filename);
if (ver == 0) { if (ver == 0) {

5
raw.c
View File

@ -15,11 +15,6 @@ static Socket s = NULL;
static void raw_size(void); static void raw_size(void);
static int sb_opt, sb_len;
static char *sb_buf = NULL;
static int sb_size = 0;
#define SB_DELTA 1024
static void c_write(char *buf, int len) static void c_write(char *buf, int len)
{ {
from_backend(0, buf, len); from_backend(0, buf, len);

View File

@ -16,11 +16,6 @@ static Socket s = NULL;
static void rlogin_size(void); static void rlogin_size(void);
static int sb_opt, sb_len;
static char *sb_buf = NULL;
static int sb_size = 0;
#define SB_DELTA 1024
static void c_write(char *buf, int len) static void c_write(char *buf, int len)
{ {
from_backend(0, buf, len); from_backend(0, buf, len);

30
scp.c
View File

@ -71,8 +71,6 @@ static void sink(char *targ, char *src);
static void tell_char(FILE * stream, char c); static void tell_char(FILE * stream, char c);
static void tell_str(FILE * stream, char *str); static void tell_str(FILE * stream, char *str);
static void tell_user(FILE * stream, char *fmt, ...); static void tell_user(FILE * stream, char *fmt, ...);
static void send_char_msg(unsigned int msg_id, char c);
static void send_str_msg(unsigned int msg_id, char *str);
static void gui_update_stats(char *name, unsigned long size, static void gui_update_stats(char *name, unsigned long size,
int percentage, unsigned long elapsed); int percentage, unsigned long elapsed);
@ -743,11 +741,9 @@ static void source(char *src)
if (response()) if (response())
return; return;
if (statistics) { stat_bytes = 0;
stat_bytes = 0; stat_starttime = time(NULL);
stat_starttime = time(NULL); stat_lasttime = 0;
stat_lasttime = 0;
}
for (i = 0; i < size; i += 4096) { for (i = 0; i < size; i += 4096) {
char transbuf[4096]; char transbuf[4096];
@ -938,17 +934,15 @@ static void sink(char *targ, char *src)
back->send("", 1); back->send("", 1);
if (statistics) { stat_bytes = 0;
stat_bytes = 0; stat_starttime = time(NULL);
stat_starttime = time(NULL); stat_lasttime = 0;
stat_lasttime = 0; if ((stat_name = strrchr(namebuf, '/')) == NULL)
if ((stat_name = strrchr(namebuf, '/')) == NULL) stat_name = namebuf;
stat_name = namebuf; else
else stat_name++;
stat_name++; if (strrchr(stat_name, '\\') != NULL)
if (strrchr(stat_name, '\\') != NULL) stat_name = strrchr(stat_name, '\\') + 1;
stat_name = strrchr(stat_name, '\\') + 1;
}
for (i = 0; i < size; i += 4096) { for (i = 0; i < size; i += 4096) {
char transbuf[4096]; char transbuf[4096];

View File

@ -271,7 +271,8 @@ void load_settings(char *section, int do_host, Config * cfg)
gppi(sesskey, "SunkenEdge", 0, &cfg->sunken_edge); gppi(sesskey, "SunkenEdge", 0, &cfg->sunken_edge);
gppi(sesskey, "CurType", 0, &cfg->cursor_type); gppi(sesskey, "CurType", 0, &cfg->cursor_type);
gppi(sesskey, "BlinkCur", 0, &cfg->blink_cur); gppi(sesskey, "BlinkCur", 0, &cfg->blink_cur);
gppi(sesskey, "Beep", 1, &cfg->beep); /* pedantic compiler tells me I can't use &cfg->beep as an int * :-) */
gppi(sesskey, "Beep", 1, &i); cfg->beep = i;
gpps(sesskey, "BellWaveFile", "", cfg->bell_wavefile, gpps(sesskey, "BellWaveFile", "", cfg->bell_wavefile,
sizeof(cfg->bell_wavefile)); sizeof(cfg->bell_wavefile));
gppi(sesskey, "BellOverload", 1, &cfg->bellovl); gppi(sesskey, "BellOverload", 1, &cfg->bellovl);

19
ssh.c
View File

@ -1322,7 +1322,7 @@ static void ssh_detect_bugs(char *vstring)
static int do_ssh_init(unsigned char c) static int do_ssh_init(unsigned char c)
{ {
static char vslen; static int vslen;
static char version[10]; static char version[10];
static char *vstring; static char *vstring;
static int vstrsize; static int vstrsize;
@ -1574,15 +1574,16 @@ static char *connect_to_host(char *host, int port, char **realhost)
*/ */
static int do_ssh1_login(unsigned char *in, int inlen, int ispkt) static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
{ {
int i, j, len; int i, j;
unsigned char *rsabuf, *keystr1, *keystr2; static int len;
static unsigned char *rsabuf, *keystr1, *keystr2;
unsigned char cookie[8]; unsigned char cookie[8];
struct RSAKey servkey, hostkey; struct RSAKey servkey, hostkey;
struct MD5Context md5c; struct MD5Context md5c;
static unsigned long supported_ciphers_mask, supported_auths_mask; static unsigned long supported_ciphers_mask, supported_auths_mask;
static int tried_publickey; static int tried_publickey;
static unsigned char session_id[16]; static unsigned char session_id[16];
int cipher_type; static int cipher_type;
static char username[100]; static char username[100];
crBegin; crBegin;
@ -1884,6 +1885,7 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
ssh1_read_bignum(pktin.body, &challenge); ssh1_read_bignum(pktin.body, &challenge);
{ {
char *agentreq, *q, *ret; char *agentreq, *q, *ret;
void *vret;
int len, retlen; int len, retlen;
len = 1 + 4; /* message type, bit count */ len = 1 + 4; /* message type, bit count */
len += ssh1_bignum_length(key.exponent); len += ssh1_bignum_length(key.exponent);
@ -1903,7 +1905,8 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
memcpy(q, session_id, 16); memcpy(q, session_id, 16);
q += 16; q += 16;
PUT_32BIT(q, 1); /* response format */ PUT_32BIT(q, 1); /* response format */
agent_query(agentreq, len + 4, &ret, &retlen); agent_query(agentreq, len + 4, &vret, &retlen);
ret = vret;
sfree(agentreq); sfree(agentreq);
if (ret) { if (ret) {
if (ret[4] == SSH1_AGENT_RSA_RESPONSE) { if (ret[4] == SSH1_AGENT_RSA_RESPONSE) {
@ -3085,8 +3088,6 @@ static void ssh2_try_send(struct ssh_channel *c)
*/ */
static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt) static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
{ {
static unsigned long remote_winsize;
static unsigned long remote_maxpkt;
static enum { static enum {
AUTH_INVALID, AUTH_PUBLICKEY_AGENT, AUTH_PUBLICKEY_FILE, AUTH_INVALID, AUTH_PUBLICKEY_AGENT, AUTH_PUBLICKEY_FILE,
AUTH_PASSWORD AUTH_PASSWORD
@ -3366,6 +3367,7 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
static int pklen, alglen, commentlen; static int pklen, alglen, commentlen;
static int siglen, retlen, len; static int siglen, retlen, len;
static char *q, *agentreq, *ret; static char *q, *agentreq, *ret;
void *vret;
{ {
char buf[64]; char buf[64];
@ -3444,7 +3446,8 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
q += pktout.length - 5; q += pktout.length - 5;
/* And finally the (zero) flags word. */ /* And finally the (zero) flags word. */
PUT_32BIT(q, 0); PUT_32BIT(q, 0);
agent_query(agentreq, len + 4, &ret, &retlen); agent_query(agentreq, len + 4, &vret, &retlen);
ret = vret;
sfree(agentreq); sfree(agentreq);
if (ret) { if (ret) {
if (ret[4] == SSH2_AGENT_SIGN_RESPONSE) { if (ret[4] == SSH2_AGENT_SIGN_RESPONSE) {

View File

@ -34,7 +34,6 @@ static unsigned char G[] = { 2 };
* Variables. * Variables.
*/ */
static Bignum x, e, p, q, qmask, g; static Bignum x, e, p, q, qmask, g;
static int need_to_free_pg;
/* /*
* Common DH initialisation. * Common DH initialisation.
@ -116,7 +115,7 @@ Bignum dh_create_e(int nbits)
} else { } else {
int b, nb; int b, nb;
x = bn_power_2(nbits); x = bn_power_2(nbits);
nb = 0; b = nb = 0;
for (i = 0; i < nbits; i++) { for (i = 0; i < nbits; i++) {
if (nb == 0) { if (nb == 0) {
nb = 8; nb = 8;

View File

@ -207,6 +207,7 @@ static void lz77_compress(struct LZ77Context *ctx,
st->npending -= i; st->npending -= i;
defermatch.len = 0; defermatch.len = 0;
deferchr = '\0';
while (len > 0) { while (len > 0) {
/* Don't even look for a match, if we're not compressing. */ /* Don't even look for a match, if we're not compressing. */
@ -519,7 +520,8 @@ static void zlib_match(struct LZ77Context *ectx, int distance, int len)
*/ */
i = -1; i = -1;
j = sizeof(lencodes) / sizeof(*lencodes); j = sizeof(lencodes) / sizeof(*lencodes);
while (j - i >= 2) { while (1) {
assert(j - i >= 2);
k = (j + i) / 2; k = (j + i) / 2;
if (thislen < lencodes[k].min) if (thislen < lencodes[k].min)
j = k; j = k;
@ -554,7 +556,8 @@ static void zlib_match(struct LZ77Context *ectx, int distance, int len)
*/ */
i = -1; i = -1;
j = sizeof(distcodes) / sizeof(*distcodes); j = sizeof(distcodes) / sizeof(*distcodes);
while (j - i >= 2) { while (1) {
assert(j - i >= 2);
k = (j + i) / 2; k = (j + i) / 2;
if (distance < distcodes[k].min) if (distance < distcodes[k].min)
j = k; j = k;
@ -656,7 +659,8 @@ int zlib_compress_block(unsigned char *block, int len,
out->firstblock = 0; out->firstblock = 0;
in_block = FALSE; in_block = FALSE;
} } else
in_block = TRUE;
if (out->comp_disabled) { if (out->comp_disabled) {
if (in_block) if (in_block)

View File

@ -358,9 +358,9 @@ void term_init(void)
*/ */
void term_size(int newrows, int newcols, int newsavelines) void term_size(int newrows, int newcols, int newsavelines)
{ {
tree234 *newsb, *newscreen, *newalt; tree234 *newalt;
unsigned long *newdisp, *oldline, *line; unsigned long *newdisp, *line;
int i, j, ccols; int i, j;
int sblen; int sblen;
int save_alt_which = alt_which; int save_alt_which = alt_which;
@ -1444,7 +1444,7 @@ void term_out(void)
case ANSI('5', '#'): case ANSI('5', '#'):
nlattr = LATTR_NORM; nlattr = LATTR_NORM;
break; break;
case ANSI('6', '#'): default: /* spiritually case ANSI('6', '#'): */
nlattr = LATTR_WIDE; nlattr = LATTR_WIDE;
break; break;
} }
@ -2064,8 +2064,10 @@ void term_out(void)
val = c - 'A' + 10; val = c - 'A' + 10;
else if (c >= 'a' && c <= 'a' + max - 10) else if (c >= 'a' && c <= 'a' + max - 10)
val = c - 'a' + 10; val = c - 'a' + 10;
else else {
termstate = TOPLEVEL; termstate = TOPLEVEL;
break;
}
osc_string[osc_strlen++] = val; osc_string[osc_strlen++] = val;
if (osc_strlen >= 7) { if (osc_strlen >= 7) {
palette_set(osc_string[0], palette_set(osc_string[0],
@ -2359,6 +2361,7 @@ void term_out(void)
ATTR_BLINK))); ATTR_BLINK)));
break; break;
#endif #endif
default: break; /* placate gcc warning about enum use */
} }
if (selstate != NO_SELECTION) { if (selstate != NO_SELECTION) {
pos cursplus = curs; pos cursplus = curs;
@ -2997,6 +3000,7 @@ void term_mouse(Mouse_Button b, Mouse_Action a, int x, int y,
case MBT_WHEEL_DOWN: case MBT_WHEEL_DOWN:
encstate = 0x61; encstate = 0x61;
break; break;
default: break; /* placate gcc warning about enum use */
} }
switch (a) { switch (a) {
case MA_DRAG: case MA_DRAG:
@ -3013,6 +3017,7 @@ void term_mouse(Mouse_Button b, Mouse_Action a, int x, int y,
return; return;
is_down = b; is_down = b;
break; break;
default: break; /* placate gcc warning about enum use */
} }
if (shift) if (shift)
encstate += 0x04; encstate += 0x04;

View File

@ -658,9 +658,10 @@ int decode_codepage(char *cp_name)
if (cp_name && *cp_name) { if (cp_name && *cp_name) {
d = cp_name; d = cp_name;
if (strnicmp(d, "cp", 2) == 0) if (tolower(d[0]) == 'c' && tolower(d[1]) == 'p')
d += 2; d += 2;
if (strnicmp(d, "ibm", 3) == 0) if (tolower(d[0]) == 'i' && tolower(d[1]) == 'b'
&& tolower(d[1]) == 'm')
d += 3; d += 3;
for (s = d; *s >= '0' && *s <= '9'; s++); for (s = d; *s >= '0' && *s <= '9'; s++);
if (*s == 0 && s != d) if (*s == 0 && s != d)

View File

@ -1142,6 +1142,7 @@ Mouse_Button translate_button(Mouse_Button button)
return cfg.mouse_is_xterm ? MBT_PASTE : MBT_EXTEND; return cfg.mouse_is_xterm ? MBT_PASTE : MBT_EXTEND;
if (button == MBT_RIGHT) if (button == MBT_RIGHT)
return cfg.mouse_is_xterm ? MBT_EXTEND : MBT_PASTE; return cfg.mouse_is_xterm ? MBT_EXTEND : MBT_PASTE;
return 0; /* shouldn't happen */
} }
static void show_mouseptr(int show) static void show_mouseptr(int show)
@ -1557,6 +1558,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
button = MBT_RIGHT; button = MBT_RIGHT;
press = 0; press = 0;
break; break;
default:
button = press = 0; /* shouldn't happen */
} }
show_mouseptr(1); show_mouseptr(1);
if (press) { if (press) {
@ -3173,7 +3176,7 @@ void get_clip(wchar_t ** p, int *len)
clipdata = NULL; clipdata = NULL;
return; return;
} else if (OpenClipboard(NULL)) { } else if (OpenClipboard(NULL)) {
if (clipdata = GetClipboardData(CF_UNICODETEXT)) { if ((clipdata = GetClipboardData(CF_UNICODETEXT))) {
CloseClipboard(); CloseClipboard();
*p = GlobalLock(clipdata); *p = GlobalLock(clipdata);
if (*p) { if (*p) {
@ -3181,7 +3184,7 @@ void get_clip(wchar_t ** p, int *len)
*len = p2 - *p; *len = p2 - *p;
return; return;
} }
} else if (clipdata = GetClipboardData(CF_TEXT)) { } else if ( (clipdata = GetClipboardData(CF_TEXT)) ) {
char *s; char *s;
int i; int i;
CloseClipboard(); CloseClipboard();

View File

@ -251,7 +251,7 @@ SockAddr sk_namelookup(char *host, char **canonicalname)
*/ */
if (ret->family == 0) { if (ret->family == 0) {
/*debug(("Resolving \"%s\" with gethostbyname() (IPv4 only)...\n", host)); */ /*debug(("Resolving \"%s\" with gethostbyname() (IPv4 only)...\n", host)); */
if (h = gethostbyname(host)) if ( (h = gethostbyname(host)) )
ret->family = AF_INET; ret->family = AF_INET;
} }
} }
@ -363,10 +363,10 @@ static void sk_tcp_flush(Socket s)
*/ */
} }
void sk_tcp_close(Socket s); static void sk_tcp_close(Socket s);
void sk_tcp_write(Socket s, char *data, int len); static void sk_tcp_write(Socket s, char *data, int len);
void sk_tcp_write_oob(Socket s, char *data, int len); static void sk_tcp_write_oob(Socket s, char *data, int len);
char *sk_tcp_socket_error(Socket s); static char *sk_tcp_socket_error(Socket s);
Socket sk_new(SockAddr addr, int port, int privport, int oobinline, Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
Plug plug) Plug plug)