]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: tidy up types in server code
authorViktor Szakats <commit@vsz.me>
Sun, 12 May 2024 19:14:06 +0000 (21:14 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 13 May 2024 09:16:26 +0000 (11:16 +0200)
Cherry-picked from #13489
Closes #13610

tests/server/mqttd.c
tests/server/rtspd.c
tests/server/sockfilt.c
tests/server/socksd.c
tests/server/tftp.h
tests/server/tftpd.c
tests/server/util.c

index 31918956b727eb317af62b596d323c5deb05d53e..6e24f5cc24e6a06229676ab6e796b78d60067d36 100644 (file)
@@ -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 */
index 6aac06ae62fc9cd78923307af159e6582f8892a5..ba6d158ed0056cf6368527a22865019396bfd524 100644 (file)
@@ -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 */
index 27e0ebfed28f90d1b613bdc91ef251b7e6ee1e4e..8d9d13b4f47555d9dbe8ef63572d279f9784c9a2 100644 (file)
@@ -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);
index 39007e5d720fbeb622dad19ac676a53c25827098..6fd647faaa1b4b5b9d83f2bf7544ba852f9dc021 100644 (file)
@@ -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;
index 70e2197219927ee2a99308a8f244d5cb6d5a0582..a3d56b7b3c7f6dde4ecd3ad458485684b03677b6 100644 (file)
@@ -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
index 9dd634eb219451568dc1f0ac2f58dc17f4de43dc..afef684a4acde9fe6bf285ccf4e9cadfd6367bd5 100644 (file)
@@ -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)
index 74d6d08072b6ef7ea337ca3d60a2fe6b6f2d9b5a..a1355f9c0c1a19997223c6889613d05c5693f47f 100644 (file)
@@ -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);