cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: TFTP nits

From: Gisle Vanem <giva_at_bgnett.no>
Date: Mon, 05 Sep 2005 17:07:27 +0200

> Mingw32 cross-compiled on Linux, warns on argument to in sendto(). I haven't
> yet check what it actually wants it to look like:

sendto() wants 'const u_char*' in 2nd arg.
And, sockfd should be defined as curl_socket_t.

Diff.. you fix the long lines?

-----------------------------------

Index: tftp.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/tftp.c,v
retrieving revision 1.2
diff -u -r1.2 tftp.c
--- tftp.c 4 Sep 2005 18:33:20 -0000 1.2
+++ tftp.c 5 Sep 2005 15:04:15 -0000
@@ -147,7 +147,7 @@
   tftp_mode_t mode;
   tftp_error_t error;
   struct connectdata *conn;
- int sockfd;
+ curl_socket_t sockfd;
   int retries;
   int retry_time;
   int retry_max;
@@ -275,7 +275,7 @@
     sprintf((char *)state->spacket.u.request.data, "%s%c%s%c",
             filename, '\0', mode, '\0');
     sbytes = 4 + strlen(filename) + strlen(mode);
- sbytes = sendto(state->sockfd, &state->spacket, sbytes, 0,
+ sbytes = sendto(state->sockfd, (const u_char*)&state->spacket, sbytes, 0,
                     state->conn->ip_addr->ai_addr,
                     state->conn->ip_addr->ai_addrlen);
     if(sbytes < 0) {
@@ -341,7 +341,7 @@
     state->retries = 0;
     state->spacket.event = htons(TFTP_EVENT_ACK);
     state->spacket.u.ack.block = htons(state->block);
- sbytes = sendto(state->sockfd, &state->spacket, 4, MSG_NOSIGNAL,
+ sbytes = sendto(state->sockfd, (const u_char*)&state->spacket, 4, MSG_NOSIGNAL,
                     &state->remote_addr, state->remote_addrlen);
     if(sbytes < 0) {
       failf(state->conn->data, "%s\n", strerror(errno));
@@ -366,7 +366,7 @@
       state->state = TFTP_STATE_FIN;
     } else {
       /* Resend the previous ACK */
- sbytes = sendto(state->sockfd, &state->spacket,
+ sbytes = sendto(state->sockfd, (const u_char*)&state->spacket,
                       4, MSG_NOSIGNAL,
                       &state->remote_addr, state->remote_addrlen);
       /* Check all sbytes were sent */
@@ -431,7 +431,7 @@
       return;
     }
     Curl_fillreadbuffer(state->conn, 512, &state->sbytes);
- sbytes = sendto(state->sockfd, &state->spacket,
+ sbytes = sendto(state->sockfd, (const u_char*)&state->spacket,
                     4+state->sbytes, MSG_NOSIGNAL,
                     &state->remote_addr, state->remote_addrlen);
     /* Check all sbytes were sent */
@@ -453,7 +453,7 @@
       state->state = TFTP_STATE_FIN;
     } else {
       /* Re-send the data packet */
- sbytes = sendto(state->sockfd, &state->spacket,
+ sbytes = sendto(state->sockfd, (const u_char*)&state->spacket,
                       4+state->sbytes, MSG_NOSIGNAL,
                       &state->remote_addr, state->remote_addrlen);
       /* Check all sbytes were sent */

-----------------------------------

--gv
Received on 2005-09-05