tests: tidy up types in server code

Cherry-picked from #13489
Closes #13610
This commit is contained in:
Viktor Szakats 2024-05-12 21:14:06 +02:00
Родитель 7333faf00b
Коммит 0c49ea4ff2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5ABD165E2AEF201
7 изменённых файлов: 29 добавлений и 29 удалений

Просмотреть файл

@ -343,10 +343,10 @@ static int disconnect(FILE *dump, curl_socket_t fd)
*/
/* return number of bytes used */
static int encode_length(size_t packetlen,
unsigned char *remlength) /* 4 bytes */
static size_t encode_length(size_t packetlen,
unsigned char *remlength) /* 4 bytes */
{
int bytes = 0;
size_t bytes = 0;
unsigned char encode;
do {
@ -396,12 +396,12 @@ static int publish(FILE *dump,
size_t topiclen = strlen(topic);
unsigned char *packet;
size_t payloadindex;
ssize_t remaininglength = topiclen + 2 + payloadlen;
ssize_t packetlen;
ssize_t sendamount;
size_t remaininglength = topiclen + 2 + payloadlen;
size_t packetlen;
size_t sendamount;
ssize_t rc;
unsigned char rembuffer[4];
int encodedlen;
size_t encodedlen;
if(config.excessive_remaining) {
/* manually set illegal remaining length */
@ -443,7 +443,7 @@ static int publish(FILE *dump,
loghex(packet, rc);
logprotocol(FROM_SERVER, "PUBLISH", remaininglength, dump, packet, rc);
}
if(rc == packetlen)
if((size_t)rc == packetlen)
return 0;
return 1;
}
@ -463,7 +463,7 @@ static int fixedheader(curl_socket_t fd,
/* get the first two bytes */
ssize_t rc = sread(fd, (char *)buffer, 2);
int i;
size_t i;
if(rc < 2) {
logmsg("READ %zd bytes [SHORT!]", rc);
return 1; /* fail */

Просмотреть файл

@ -89,10 +89,10 @@ typedef enum {
RPROT_HTTP = 2
} reqprot_t;
#define SET_RTP_PKT_CHN(p,c) ((p)[1] = (unsigned char)((c) & 0xFF))
#define SET_RTP_PKT_CHN(p,c) ((p)[1] = (char)((c) & 0xFF))
#define SET_RTP_PKT_LEN(p,l) (((p)[2] = (unsigned char)(((l) >> 8) & 0xFF)), \
((p)[3] = (unsigned char)((l) & 0xFF)))
#define SET_RTP_PKT_LEN(p,l) (((p)[2] = (char)(((l) >> 8) & 0xFF)), \
((p)[3] = (char)((l) & 0xFF)))
struct httprequest {
char reqbuf[REQBUFSIZ]; /* buffer area for the incoming request */

Просмотреть файл

@ -179,7 +179,7 @@ static ssize_t read_wincon(int fd, void *buf, size_t count)
return rcount;
}
errno = GetLastError();
errno = (int)GetLastError();
return -1;
}
#undef read
@ -214,7 +214,7 @@ static ssize_t write_wincon(int fd, const void *buf, size_t count)
return wcount;
}
errno = GetLastError();
errno = (int)GetLastError();
return -1;
}
#undef write
@ -483,7 +483,7 @@ static unsigned int WINAPI select_ws_wait_thread(void *lpParameter)
size.LowPart = GetFileSize(handle, &length);
if((size.LowPart != INVALID_FILE_SIZE) ||
(GetLastError() == NO_ERROR)) {
size.HighPart = length;
size.HighPart = (LONG)length;
/* get the current position within the file */
pos.QuadPart = 0;
pos.LowPart = SetFilePointer(handle, 0, &pos.HighPart, FILE_CURRENT);

Просмотреть файл

@ -620,7 +620,7 @@ static curl_socket_t sockit(curl_socket_t fd)
memcpy(&response[SOCKS5_BNDADDR + len],
&buffer[SOCKS5_DSTADDR + len], sizeof(socksport));
rc = (send)(fd, (char *)response, (size_t)(len + 6), 0);
rc = (send)(fd, (char *)response, (SEND_TYPE_ARG3)(len + 6), 0);
if(rc != (len + 6)) {
logmsg("Sending connect response failed!");
return CURL_SOCKET_BAD;

Просмотреть файл

@ -42,9 +42,9 @@
things build. */
struct tftphdr {
short th_opcode; /* packet type */
unsigned short th_block; /* all sorts of things */
char th_data[1]; /* data or error string */
unsigned short th_opcode; /* packet type */
unsigned short th_block; /* all sorts of things */
char th_data[1]; /* data or error string */
} PACKED_STRUCT;
#define th_stuff th_block

Просмотреть файл

@ -241,7 +241,8 @@ static int synchnet(curl_socket_t);
static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size);
static int validate_access(struct testcase *test, const char *fname, int mode);
static int validate_access(struct testcase *test,
const char *filename, unsigned short mode);
static void sendtftp(struct testcase *test, const struct formats *pf);
@ -1073,7 +1074,7 @@ static int parse_servercmd(struct testcase *req)
* Validate file access.
*/
static int validate_access(struct testcase *test,
const char *filename, int mode)
const char *filename, unsigned short mode)
{
char *ptr;
@ -1183,7 +1184,7 @@ static void sendtftp(struct testcase *test, const struct formats *pf)
nak(errno + 100);
return;
}
sdp->th_opcode = htons((unsigned short)opcode_DATA);
sdp->th_opcode = htons(opcode_DATA);
sdp->th_block = htons(sendblock);
timeout = 0;
#ifdef HAVE_SIGSETJMP
@ -1218,7 +1219,7 @@ send_data:
logmsg("read: fail");
return;
}
sap->th_opcode = ntohs((unsigned short)sap->th_opcode);
sap->th_opcode = ntohs(sap->th_opcode);
sap->th_block = ntohs(sap->th_block);
if(sap->th_opcode == opcode_ERROR) {
@ -1261,7 +1262,7 @@ static void recvtftp(struct testcase *test, const struct formats *pf)
rap = &ackbuf.hdr;
do {
timeout = 0;
rap->th_opcode = htons((unsigned short)opcode_ACK);
rap->th_opcode = htons(opcode_ACK);
rap->th_block = htons(recvblock);
recvblock++;
#ifdef HAVE_SIGSETJMP
@ -1290,7 +1291,7 @@ send_ack:
logmsg("read: fail");
goto abort;
}
rdp->th_opcode = ntohs((unsigned short)rdp->th_opcode);
rdp->th_opcode = ntohs(rdp->th_opcode);
rdp->th_block = ntohs(rdp->th_block);
if(rdp->th_opcode == opcode_ERROR)
goto abort;
@ -1321,8 +1322,7 @@ send_ack:
test->ofile = 0;
}
rap->th_opcode = htons((unsigned short)opcode_ACK); /* send the "final"
ack */
rap->th_opcode = htons(opcode_ACK); /* send the "final" ack */
rap->th_block = htons(recvblock);
(void) swrite(peer, &ackbuf.storage[0], 4);
#if defined(HAVE_ALARM) && defined(SIGALRM)
@ -1361,7 +1361,7 @@ static void nak(int error)
struct errmsg *pe;
tp = &buf.hdr;
tp->th_opcode = htons((unsigned short)opcode_ERROR);
tp->th_opcode = htons(opcode_ERROR);
tp->th_code = htons((unsigned short)error);
for(pe = errmsgs; pe->e_code >= 0; pe++)
if(pe->e_code == error)

Просмотреть файл

@ -147,7 +147,7 @@ static const char *win32_strerror(int err, char *buf, size_t buflen)
void win32_perror(const char *msg)
{
char buf[512];
DWORD err = SOCKERRNO;
int err = SOCKERRNO;
win32_strerror(err, buf, sizeof(buf));
if(msg)
fprintf(stderr, "%s: ", msg);