mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Make lots of 'int' length fields into size_t.
This is a general cleanup which has been overdue for some time: lots of length fields are now the machine word type rather than the (in practice) fixed 'int'.
This commit is contained in:
@ -388,7 +388,7 @@ static void console_eventlog(LogPolicy *lp, const char *string)
|
||||
console_logging_error(lp, string);
|
||||
}
|
||||
|
||||
static void console_data_untrusted(HANDLE hout, const char *data, int len)
|
||||
static void console_data_untrusted(HANDLE hout, const char *data, size_t len)
|
||||
{
|
||||
DWORD dummy;
|
||||
bufchain sanitised;
|
||||
@ -465,7 +465,7 @@ int console_get_userpass_input(prompts_t *p)
|
||||
for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
|
||||
|
||||
DWORD savemode, newmode;
|
||||
int len;
|
||||
size_t len;
|
||||
prompt_t *pr = p->prompts[curr_prompt];
|
||||
|
||||
GetConsoleMode(hin, &savemode);
|
||||
@ -486,7 +486,7 @@ int console_get_userpass_input(prompts_t *p)
|
||||
|
||||
if (!ReadFile(hin, pr->result + len, pr->resultsize - len - 1,
|
||||
&ret, NULL) || ret == 0) {
|
||||
len = -1;
|
||||
len = (size_t)-1;
|
||||
break;
|
||||
}
|
||||
len += ret;
|
||||
@ -505,7 +505,7 @@ int console_get_userpass_input(prompts_t *p)
|
||||
WriteFile(hout, "\r\n", 2, &dummy, NULL);
|
||||
}
|
||||
|
||||
if (len < 0) {
|
||||
if (len == (size_t)-1) {
|
||||
return 0; /* failure due to read error */
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,8 @@ bool win_seat_get_window_pixel_size(Seat *seat, int *x, int *y)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int win_seat_output(Seat *seat, bool is_stderr, const void *, int);
|
||||
static size_t win_seat_output(
|
||||
Seat *seat, bool is_stderr, const void *, size_t);
|
||||
static bool win_seat_eof(Seat *seat);
|
||||
static int win_seat_get_userpass_input(
|
||||
Seat *seat, prompts_t *p, bufchain *input);
|
||||
@ -5784,8 +5785,8 @@ static void flip_full_screen()
|
||||
}
|
||||
}
|
||||
|
||||
static int win_seat_output(Seat *seat, bool is_stderr,
|
||||
const void *data, int len)
|
||||
static size_t win_seat_output(Seat *seat, bool is_stderr,
|
||||
const void *data, size_t len)
|
||||
{
|
||||
return term_data(term, is_stderr, data, len);
|
||||
}
|
||||
|
@ -348,12 +348,12 @@ static DWORD WINAPI handle_output_threadfunc(void *param)
|
||||
static void handle_try_output(struct handle_output *ctx)
|
||||
{
|
||||
void *senddata;
|
||||
int sendlen;
|
||||
size_t sendlen;
|
||||
|
||||
if (!ctx->busy && bufchain_size(&ctx->queued_data)) {
|
||||
bufchain_prefix(&ctx->queued_data, &senddata, &sendlen);
|
||||
ctx->buffer = senddata;
|
||||
ctx->len = sendlen;
|
||||
ctx->len = min(sendlen, ~(DWORD)0);
|
||||
SetEvent(ctx->ev_from_main);
|
||||
ctx->busy = true;
|
||||
} else if (!ctx->busy && bufchain_size(&ctx->queued_data) == 0 &&
|
||||
@ -515,7 +515,7 @@ struct handle *handle_add_foreign_event(HANDLE event,
|
||||
return h;
|
||||
}
|
||||
|
||||
int handle_write(struct handle *h, const void *data, int len)
|
||||
size_t handle_write(struct handle *h, const void *data, size_t len)
|
||||
{
|
||||
assert(h->type == HT_OUTPUT);
|
||||
assert(h->u.o.outgoingeof == EOF_NO);
|
||||
@ -702,13 +702,13 @@ void handle_got_event(HANDLE event)
|
||||
}
|
||||
}
|
||||
|
||||
void handle_unthrottle(struct handle *h, int backlog)
|
||||
void handle_unthrottle(struct handle *h, size_t backlog)
|
||||
{
|
||||
assert(h->type == HT_INPUT);
|
||||
handle_throttle(&h->u.i, backlog);
|
||||
}
|
||||
|
||||
int handle_backlog(struct handle *h)
|
||||
size_t handle_backlog(struct handle *h)
|
||||
{
|
||||
assert(h->type == HT_OUTPUT);
|
||||
return bufchain_size(&h->u.o.queued_data);
|
||||
|
@ -45,7 +45,8 @@ typedef struct HandleSocket {
|
||||
Socket sock;
|
||||
} HandleSocket;
|
||||
|
||||
static int handle_gotdata(struct handle *h, const void *data, int len, int err)
|
||||
static size_t handle_gotdata(
|
||||
struct handle *h, const void *data, size_t len, int err)
|
||||
{
|
||||
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
|
||||
|
||||
@ -79,7 +80,8 @@ static int handle_gotdata(struct handle *h, const void *data, int len, int err)
|
||||
}
|
||||
}
|
||||
|
||||
static int handle_stderr(struct handle *h, const void *data, int len, int err)
|
||||
static size_t handle_stderr(
|
||||
struct handle *h, const void *data, size_t len, int err)
|
||||
{
|
||||
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
|
||||
|
||||
@ -89,7 +91,7 @@ static int handle_stderr(struct handle *h, const void *data, int len, int err)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void handle_sentdata(struct handle *h, int new_backlog, int err)
|
||||
static void handle_sentdata(struct handle *h, size_t new_backlog, int err)
|
||||
{
|
||||
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
|
||||
|
||||
@ -130,14 +132,14 @@ static void sk_handle_close(Socket *s)
|
||||
sfree(hs);
|
||||
}
|
||||
|
||||
static int sk_handle_write(Socket *s, const void *data, int len)
|
||||
static size_t sk_handle_write(Socket *s, const void *data, size_t len)
|
||||
{
|
||||
HandleSocket *hs = container_of(s, HandleSocket, sock);
|
||||
|
||||
return handle_write(hs->send_h, data, len);
|
||||
}
|
||||
|
||||
static int sk_handle_write_oob(Socket *s, const void *data, int len)
|
||||
static size_t sk_handle_write_oob(Socket *s, const void *data, size_t len)
|
||||
{
|
||||
/*
|
||||
* oob data is treated as inband; nasty, but nothing really
|
||||
@ -163,7 +165,7 @@ static void handle_socket_unfreeze(void *hsv)
|
||||
{
|
||||
HandleSocket *hs = (HandleSocket *)hsv;
|
||||
void *data;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
/*
|
||||
* If we've been put into a state other than THAWING since the
|
||||
|
@ -60,7 +60,7 @@ struct NetSocket {
|
||||
* notification while we were frozen */
|
||||
bool localhost_only; /* for listening sockets */
|
||||
char oobdata[1];
|
||||
int sending_oob;
|
||||
size_t sending_oob;
|
||||
bool oobinline, nodelay, keepalive, privport;
|
||||
enum { EOF_NO, EOF_PENDING, EOF_SENT } outgoingeof;
|
||||
SockAddr *addr;
|
||||
@ -832,8 +832,8 @@ static void sk_net_flush(Socket *s)
|
||||
}
|
||||
|
||||
static void sk_net_close(Socket *s);
|
||||
static int sk_net_write(Socket *s, const void *data, int len);
|
||||
static int sk_net_write_oob(Socket *s, const void *data, int len);
|
||||
static size_t sk_net_write(Socket *s, const void *data, size_t len);
|
||||
static size_t sk_net_write_oob(Socket *s, const void *data, size_t len);
|
||||
static void sk_net_write_eof(Socket *s);
|
||||
static void sk_net_set_frozen(Socket *s, bool is_frozen);
|
||||
static const char *sk_net_socket_error(Socket *s);
|
||||
@ -1378,7 +1378,8 @@ void try_send(NetSocket *s)
|
||||
int nsent;
|
||||
DWORD err;
|
||||
void *data;
|
||||
int len, urgentflag;
|
||||
size_t len;
|
||||
int urgentflag;
|
||||
|
||||
if (s->sending_oob) {
|
||||
urgentflag = MSG_OOB;
|
||||
@ -1388,6 +1389,7 @@ void try_send(NetSocket *s)
|
||||
urgentflag = 0;
|
||||
bufchain_prefix(&s->output_data, &data, &len);
|
||||
}
|
||||
len = min(len, INT_MAX); /* WinSock send() takes an int */
|
||||
nsent = p_send(s->s, data, len, urgentflag);
|
||||
noise_ultralight(NOISE_SOURCE_IOLEN, nsent);
|
||||
if (nsent <= 0) {
|
||||
@ -1443,7 +1445,7 @@ void try_send(NetSocket *s)
|
||||
}
|
||||
}
|
||||
|
||||
static int sk_net_write(Socket *sock, const void *buf, int len)
|
||||
static size_t sk_net_write(Socket *sock, const void *buf, size_t len)
|
||||
{
|
||||
NetSocket *s = container_of(sock, NetSocket, sock);
|
||||
|
||||
@ -1463,7 +1465,7 @@ static int sk_net_write(Socket *sock, const void *buf, int len)
|
||||
return bufchain_size(&s->output_data);
|
||||
}
|
||||
|
||||
static int sk_net_write_oob(Socket *sock, const void *buf, int len)
|
||||
static size_t sk_net_write_oob(Socket *sock, const void *buf, size_t len)
|
||||
{
|
||||
NetSocket *s = container_of(sock, NetSocket, sock);
|
||||
|
||||
|
@ -61,7 +61,8 @@ static void plink_echoedit_update(Seat *seat, bool echo, bool edit)
|
||||
SetConsoleMode(inhandle, mode);
|
||||
}
|
||||
|
||||
static int plink_output(Seat *seat, bool is_stderr, const void *data, int len)
|
||||
static size_t plink_output(
|
||||
Seat *seat, bool is_stderr, const void *data, size_t len)
|
||||
{
|
||||
if (is_stderr) {
|
||||
handle_write(stderr_handle, data, len);
|
||||
@ -205,7 +206,7 @@ char *do_select(SOCKET skt, bool startup)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int stdin_gotdata(struct handle *h, const void *data, int len, int err)
|
||||
size_t stdin_gotdata(struct handle *h, const void *data, size_t len, int err)
|
||||
{
|
||||
if (err) {
|
||||
char buf[4096];
|
||||
@ -217,6 +218,7 @@ int stdin_gotdata(struct handle *h, const void *data, int len, int err)
|
||||
fprintf(stderr, "Unable to read from standard input: %s\n", buf);
|
||||
cleanup_exit(0);
|
||||
}
|
||||
|
||||
noise_ultralight(NOISE_SOURCE_IOLEN, len);
|
||||
if (backend_connected(backend)) {
|
||||
if (len > 0) {
|
||||
@ -229,7 +231,7 @@ int stdin_gotdata(struct handle *h, const void *data, int len, int err)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stdouterr_sent(struct handle *h, int new_backlog, int err)
|
||||
void stdouterr_sent(struct handle *h, size_t new_backlog, int err)
|
||||
{
|
||||
if (err) {
|
||||
char buf[4096];
|
||||
|
@ -40,8 +40,8 @@ static void serial_terminate(Serial *serial)
|
||||
}
|
||||
}
|
||||
|
||||
static int serial_gotdata(
|
||||
struct handle *h, const void *data, int len, int err)
|
||||
static size_t serial_gotdata(
|
||||
struct handle *h, const void *data, size_t len, int err)
|
||||
{
|
||||
Serial *serial = (Serial *)handle_get_privdata(h);
|
||||
if (err || len == 0) {
|
||||
@ -73,7 +73,7 @@ static int serial_gotdata(
|
||||
}
|
||||
}
|
||||
|
||||
static void serial_sentdata(struct handle *h, int new_backlog, int err)
|
||||
static void serial_sentdata(struct handle *h, size_t new_backlog, int err)
|
||||
{
|
||||
Serial *serial = (Serial *)handle_get_privdata(h);
|
||||
if (err) {
|
||||
@ -295,7 +295,7 @@ static void serial_reconfig(Backend *be, Conf *conf)
|
||||
/*
|
||||
* Called to send data down the serial connection.
|
||||
*/
|
||||
static int serial_send(Backend *be, const char *buf, int len)
|
||||
static size_t serial_send(Backend *be, const char *buf, size_t len)
|
||||
{
|
||||
Serial *serial = container_of(be, Serial, backend);
|
||||
|
||||
@ -309,7 +309,7 @@ static int serial_send(Backend *be, const char *buf, int len)
|
||||
/*
|
||||
* Called to query the current sendability status.
|
||||
*/
|
||||
static int serial_sendbuffer(Backend *be)
|
||||
static size_t serial_sendbuffer(Backend *be)
|
||||
{
|
||||
Serial *serial = container_of(be, Serial, backend);
|
||||
return serial->bufsize;
|
||||
@ -386,7 +386,7 @@ static bool serial_sendok(Backend *be)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void serial_unthrottle(Backend *be, int backlog)
|
||||
static void serial_unthrottle(Backend *be, size_t backlog)
|
||||
{
|
||||
Serial *serial = container_of(be, Serial, backend);
|
||||
if (serial->in)
|
||||
|
@ -603,21 +603,21 @@ void init_ucs(Conf *, struct unicode_data *);
|
||||
#define HANDLE_FLAG_IGNOREEOF 2
|
||||
#define HANDLE_FLAG_UNITBUFFER 4
|
||||
struct handle;
|
||||
typedef int (*handle_inputfn_t)(
|
||||
struct handle *h, const void *data, int len, int err);
|
||||
typedef size_t (*handle_inputfn_t)(
|
||||
struct handle *h, const void *data, size_t len, int err);
|
||||
typedef void (*handle_outputfn_t)(
|
||||
struct handle *h, int new_backlog, int err);
|
||||
struct handle *h, size_t new_backlog, int err);
|
||||
struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata,
|
||||
void *privdata, int flags);
|
||||
struct handle *handle_output_new(HANDLE handle, handle_outputfn_t sentdata,
|
||||
void *privdata, int flags);
|
||||
int handle_write(struct handle *h, const void *data, int len);
|
||||
size_t handle_write(struct handle *h, const void *data, size_t len);
|
||||
void handle_write_eof(struct handle *h);
|
||||
HANDLE *handle_get_events(int *nevents);
|
||||
void handle_free(struct handle *h);
|
||||
void handle_got_event(HANDLE event);
|
||||
void handle_unthrottle(struct handle *h, int backlog);
|
||||
int handle_backlog(struct handle *h);
|
||||
void handle_unthrottle(struct handle *h, size_t backlog);
|
||||
size_t handle_backlog(struct handle *h);
|
||||
void *handle_get_privdata(struct handle *h);
|
||||
struct handle *handle_add_foreign_event(HANDLE event,
|
||||
void (*callback)(void *), void *ctx);
|
||||
|
Reference in New Issue
Block a user