]> granicus.if.org Git - curl/commitdiff
TFTP: fix warning for sendto() usage on non-POSIX systems
authorDaniel Stenberg <daniel@haxx.se>
Tue, 8 Jun 2010 08:19:39 +0000 (10:19 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 8 Jun 2010 08:19:39 +0000 (10:19 +0200)
Older unixes want an 'int' instead of 'size_t' as the 3rd
argumment so before this change it would cause warnings such as:

There is an implicit conversion from "unsigned long" to "int";
rounding, sign extension, or loss of accuracy may result.

lib/tftp.c

index 166954f85ccd87966c66263f5afec7dd4c009f0a..c09aadc03ee8b41e57d67af433b1d790ef54f1d9 100644 (file)
@@ -535,10 +535,12 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
     sbytes += tftp_option_add(state, sbytes,
                               (char *)state->spacket.data+sbytes, buf );
 
+    /* the typecase for the 3rd argument is mostly for systems that do
+       not have a size_t argument, like older unixes that want an 'int' */
     senddata = sendto(state->sockfd, (void *)state->spacket.data,
-                    sbytes, 0,
-                    state->conn->ip_addr->ai_addr,
-                    state->conn->ip_addr->ai_addrlen);
+                      (SEND_TYPE_ARG3)sbytes, 0,
+                      state->conn->ip_addr->ai_addr,
+                      state->conn->ip_addr->ai_addrlen);
     if(senddata != (ssize_t)sbytes) {
       failf(data, "%s", Curl_strerror(state->conn, SOCKERRNO));
     }