*/
/* 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 {
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 */
loghex(packet, rc);
logprotocol(FROM_SERVER, "PUBLISH", remaininglength, dump, packet, rc);
}
- if(rc == packetlen)
+ if((size_t)rc == packetlen)
return 0;
return 1;
}
/* 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 */
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 */
return rcount;
}
- errno = GetLastError();
+ errno = (int)GetLastError();
return -1;
}
#undef read
return wcount;
}
- errno = GetLastError();
+ errno = (int)GetLastError();
return -1;
}
#undef write
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);
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;
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
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);
* Validate file access.
*/
static int validate_access(struct testcase *test,
- const char *filename, int mode)
+ const char *filename, unsigned short mode)
{
char *ptr;
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
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) {
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
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;
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)
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)
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);