From fcb5e7c438d5787ea34802bdb458c0bb52ed69ba Mon Sep 17 00:00:00 2001 From: Stefan Sommerfeld Date: Sun, 7 Nov 2010 15:16:33 -0200 Subject: [PATCH] Fix for size_t related warnings. --- upnp/inc/upnp.h | 6 ++-- upnp/src/api/upnpapi.c | 8 ++--- upnp/src/gena/gena_device.c | 6 ++-- upnp/src/genlib/miniserver/miniserver.c | 6 ++-- upnp/src/genlib/net/http/httpreadwrite.c | 46 ++++++++++++------------ upnp/src/inc/httpreadwrite.h | 20 +++++------ 6 files changed, 47 insertions(+), 45 deletions(-) diff --git a/upnp/inc/upnp.h b/upnp/inc/upnp.h index 68d2eef..7b9dccb 100644 --- a/upnp/inc/upnp.h +++ b/upnp/inc/upnp.h @@ -2412,7 +2412,7 @@ EXPORT_SPEC int UpnpReadHttpGet( /*! [in,out] The buffer to store the read item. */ char *buf, /*! [in,out] The size of the buffer to be read. */ - unsigned int *size, + size_t *size, /*! [in] The time out value sent with the request during which a response is * expected from the server, failing which, an error is reported back to * the user. */ @@ -2431,9 +2431,9 @@ EXPORT_SPEC int UpnpHttpGetProgress( /*! [in] The token created by the call to \b UpnpOpenHttpGet. */ void *handle, /*! [out] The number of bytes received. */ - unsigned int *length, + size_t *length, /*! [out] The content length. */ - unsigned int *total); + size_t *total); /*! diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index ad9c62e..d67895c 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -1440,12 +1440,12 @@ static int GetDescDocumentAndURL( if (fp == NULL) { return UPNP_E_FILE_NOT_FOUND; } - membuf = (char *)malloc(fileLen + 1); + membuf = (char *)malloc((size_t) fileLen + 1); if (membuf == NULL) { fclose(fp); return UPNP_E_OUTOF_MEMORY; } - num_read = fread(membuf, 1, fileLen, fp); + num_read = fread(membuf, 1, (size_t) fileLen, fp); if (num_read != fileLen) { fclose(fp); free(membuf); @@ -2877,13 +2877,13 @@ int UpnpCloseHttpGet(void *Handle) } -int UpnpReadHttpGet(void *Handle, char *buf, unsigned int *size, int timeout) +int UpnpReadHttpGet(void *Handle, char *buf, size_t *size, int timeout) { return http_ReadHttpGet(Handle, buf, size, timeout); } -int UpnpHttpGetProgress(void *Handle, unsigned int *length, unsigned int *total) +int UpnpHttpGetProgress(void *Handle, size_t *length, size_t *total) { return http_HttpGetProgress(Handle, length, total); } diff --git a/upnp/src/gena/gena_device.c b/upnp/src/gena/gena_device.c index d99c547..015d991 100644 --- a/upnp/src/gena/gena_device.c +++ b/upnp/src/gena/gena_device.c @@ -102,7 +102,7 @@ static int GeneratePropertySet( { char *buffer; int counter = 0; - int size = 0; + size_t size = 0; int temp_counter = 0; /*size += strlen(XML_VERSION);*/ @@ -445,7 +445,7 @@ static char *AllocGenaHeaders( static const char *HEADER_LINE_4 = "NTS: upnp:propchange\r\n"; char *headers = NULL; - int headers_size = 0; + size_t headers_size = 0; int line = 0; headers_size = @@ -1133,7 +1133,7 @@ static int create_url_list( URL_list *out) { int URLcount = 0; - int i; + size_t i; int return_code = 0; uri_type temp; token urls; diff --git a/upnp/src/genlib/miniserver/miniserver.c b/upnp/src/genlib/miniserver/miniserver.c index 33f166f..38257f5 100644 --- a/upnp/src/genlib/miniserver/miniserver.c +++ b/upnp/src/genlib/miniserver/miniserver.c @@ -928,7 +928,7 @@ int StopMiniServer() SOCKET sock; struct sockaddr_in ssdpAddr; char buf[256] = "ShutDown"; - int bufLen = strlen(buf); + size_t bufLen = strlen(buf); if(gMServState == MSERV_RUNNING) { gMServState = MSERV_STOPPING; @@ -947,8 +947,8 @@ int StopMiniServer() ssdpAddr.sin_family = AF_INET; ssdpAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); ssdpAddr.sin_port = htons(miniStopSockPort); - sendto(sock, buf, bufLen, 0, (struct sockaddr *)&ssdpAddr, - socklen); + sendto(sock, buf, (int)bufLen, 0, + (struct sockaddr *)&ssdpAddr, socklen); usleep(1000); if (gMServState == MSERV_IDLE) { break; diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index 252a238..fb85884 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -1440,10 +1440,10 @@ ReadResponseLineAndHeaders( IN SOCKINFO * info, * Function: http_ReadHttpGet * * Parameters: - * IN void *Handle; Handle to the HTTP get object - * IN OUT char *buf; Buffer to get the read and parsed data - * IN OUT unsigned int *size; Size of the buffer passed - * IN int timeout; time out value + * IN void *Handle; Handle to the HTTP get object + * IN OUT char *buf; Buffer to get the read and parsed data + * IN OUT size_t *size; Size of the buffer passed + * IN int timeout; time out value * * Description: * Parses already existing data, then gets new data. @@ -1456,11 +1456,11 @@ ReadResponseLineAndHeaders( IN SOCKINFO * info, * UPNP_E_BAD_HTTPMSG * UPNP_E_CANCELED ************************************************************************/ -int -http_ReadHttpGet( IN void *Handle, - IN OUT char *buf, - IN OUT unsigned int *size, - IN int timeout ) +int http_ReadHttpGet( + IN void *Handle, + IN OUT char *buf, + IN OUT size_t *size, + IN int timeout) { http_get_handle_t *handle = Handle; @@ -1567,9 +1567,9 @@ http_ReadHttpGet( IN void *Handle, * Function: http_HttpGetProgress * * Parameters: - * IN void *Handle; Handle to the HTTP get object - * OUT unsigned int *length; Buffer to get the read and parsed data - * OUT unsigned int *total; Size of tge buffer passed + * IN void *Handle; Handle to the HTTP get object + * OUT size_t *length; Buffer to get the read and parsed data + * OUT size_t *total; Size of tge buffer passed * * Description: * Extracts information from the Handle to the HTTP get object. @@ -1578,18 +1578,20 @@ http_ReadHttpGet( IN void *Handle, * UPNP_E_SUCCESS - On Sucess * UPNP_E_INVALID_PARAM - Invalid Parameter ************************************************************************/ -int http_HttpGetProgress( IN void *Handle, - OUT unsigned int *length, - OUT unsigned int *total ) +int http_HttpGetProgress( + IN void *Handle, + OUT size_t *length, + OUT size_t *total) { - http_get_handle_t *handle = Handle; + http_get_handle_t *handle = Handle; - if( ( !handle ) || ( !length ) || ( !total ) ) { - return UPNP_E_INVALID_PARAM; - } - *length = handle->response.msg.entity.length; - *total = handle->response.content_length; - return UPNP_E_SUCCESS; + if (!handle || !length || !total) { + return UPNP_E_INVALID_PARAM; + } + *length = handle->response.msg.entity.length; + *total = handle->response.content_length; + + return UPNP_E_SUCCESS; } /************************************************************************ diff --git a/upnp/src/inc/httpreadwrite.h b/upnp/src/inc/httpreadwrite.h index cb61994..40ba2fd 100644 --- a/upnp/src/inc/httpreadwrite.h +++ b/upnp/src/inc/httpreadwrite.h @@ -313,10 +313,10 @@ int http_OpenHttpPost(IN const char *url_str, * Function: http_ReadHttpGet * * Parameters: - * IN void *Handle; Handle to the HTTP get object - * IN OUT char *buf; Buffer to get the read and parsed data - * IN OUT unsigned int *size; Size of the buffer passed - * IN int timeout; time out value + * IN void *Handle; Handle to the HTTP get object + * IN OUT char *buf; Buffer to get the read and parsed data + * IN OUT size_t *size; Size of the buffer passed + * IN int timeout; time out value * * Description: * Parses already existing data, then gets new data. @@ -332,7 +332,7 @@ int http_OpenHttpPost(IN const char *url_str, int http_ReadHttpGet( IN void *Handle, IN OUT char *buf, - IN OUT unsigned int *size, + IN OUT size_t *size, IN int timeout); @@ -340,9 +340,9 @@ int http_ReadHttpGet( * Function: http_HttpGetProgress * * Parameters: - * IN void *Handle; Handle to the HTTP get object - * OUT unsigned int *length; Buffer to get the read and parsed data - * OUT unsigned int *total; Size of tge buffer passed + * IN void *Handle; Handle to the HTTP get object + * OUT size_t *length; Buffer to get the read and parsed data + * OUT size_t *total; Size of tge buffer passed * * Description: * Extracts information from the Handle to the HTTP get object. @@ -353,8 +353,8 @@ int http_ReadHttpGet( ************************************************************************/ int http_HttpGetProgress( IN void *Handle, - OUT unsigned int *length, - OUT unsigned int *total ); + OUT size_t *length, + OUT size_t *total); /************************************************************************