mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Fix a couple of compiler warnings
This commit is contained in:
parent
93d59520e4
commit
fdbe0df6e7
24
src/main.c
24
src/main.c
@ -2594,9 +2594,9 @@ struct OutStruct {
|
|||||||
curl_off_t init; /* original size (non-zero when appending) */
|
curl_off_t init; /* original size (non-zero when appending) */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
|
static size_t my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
|
||||||
{
|
{
|
||||||
int rc;
|
size_t rc;
|
||||||
struct OutStruct *out=(struct OutStruct *)stream;
|
struct OutStruct *out=(struct OutStruct *)stream;
|
||||||
struct Configurable *config = out->config;
|
struct Configurable *config = out->config;
|
||||||
curl_off_t size = (curl_off_t)(sz * nmemb); /* typecast to prevent
|
curl_off_t size = (curl_off_t)(sz * nmemb); /* typecast to prevent
|
||||||
@ -2607,7 +2607,14 @@ static int my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
|
|||||||
out->stream=fopen(out->filename, "wb");
|
out->stream=fopen(out->filename, "wb");
|
||||||
if(!out->stream) {
|
if(!out->stream) {
|
||||||
warnf(config, "Failed to create the file %s\n", out->filename);
|
warnf(config, "Failed to create the file %s\n", out->filename);
|
||||||
return -1; /* failure */
|
/*
|
||||||
|
* Once that libcurl has called back my_fwrite() the returned value
|
||||||
|
* is checked against the amount that was intended to be written, if
|
||||||
|
* it does not match then it fails with CURLE_WRITE_ERROR. So at this
|
||||||
|
* point returning a value different from sz*nmemb indicates failure.
|
||||||
|
*/
|
||||||
|
rc = (0 == (sz * nmemb)) ? 1 : 0;
|
||||||
|
return rc; /* failure */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2662,7 +2669,7 @@ static int my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
|
|||||||
|
|
||||||
rc = fwrite(buffer, sz, nmemb, out->stream);
|
rc = fwrite(buffer, sz, nmemb, out->stream);
|
||||||
|
|
||||||
if((int)(sz * nmemb) == rc) {
|
if((sz * nmemb) == rc) {
|
||||||
/* we added this amount of data to the output */
|
/* we added this amount of data to the output */
|
||||||
out->bytes += (sz * nmemb);
|
out->bytes += (sz * nmemb);
|
||||||
}
|
}
|
||||||
@ -2700,9 +2707,9 @@ static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp)
|
|||||||
return CURLIOE_OK;
|
return CURLIOE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int my_fread(void *buffer, size_t sz, size_t nmemb, void *userp)
|
static size_t my_fread(void *buffer, size_t sz, size_t nmemb, void *userp)
|
||||||
{
|
{
|
||||||
int rc;
|
size_t rc;
|
||||||
struct InStruct *in=(struct InStruct *)userp;
|
struct InStruct *in=(struct InStruct *)userp;
|
||||||
struct Configurable *config = in->config;
|
struct Configurable *config = in->config;
|
||||||
curl_off_t size = (curl_off_t)(sz * nmemb); /* typecast to prevent warnings
|
curl_off_t size = (curl_off_t)(sz * nmemb); /* typecast to prevent warnings
|
||||||
@ -2763,7 +2770,10 @@ static int my_fread(void *buffer, size_t sz, size_t nmemb, void *userp)
|
|||||||
|
|
||||||
rc = fread(buffer, sz, nmemb, in->stream);
|
rc = fread(buffer, sz, nmemb, in->stream);
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "CALLBACK returning %d bytes data\n", (int)rc);
|
if (sizeof(rc) > sizeof(unsigned int))
|
||||||
|
fprintf(stderr, "CALLBACK returning %lu bytes data\n", rc);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "CALLBACK returning %u bytes data\n", rc);
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user