From b7528412df7cc8504fcbc7de8a6ef306b66b251c Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Tue, 10 Dec 2013 17:06:45 +1030 Subject: [PATCH] Use UINT64_MAX instead of -1 for Rhizome HTTP response content_length Fixes -Wsign-compare warnings --- rhizome.h | 2 ++ rhizome_direct_http.c | 2 +- rhizome_fetch.c | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rhizome.h b/rhizome.h index a82cdc9b..133685a6 100644 --- a/rhizome.h +++ b/rhizome.h @@ -911,6 +911,8 @@ struct http_response_parts { char *content_start; }; +#define HTTP_RESPONSE_CONTENT_LENGTH_UNSET UINT64_MAX + int unpack_http_response(char *response, struct http_response_parts *parts); /* rhizome storage methods */ diff --git a/rhizome_direct_http.c b/rhizome_direct_http.c index 09e0ef77..cf2872df 100644 --- a/rhizome_direct_http.c +++ b/rhizome_direct_http.c @@ -434,7 +434,7 @@ static int receive_http_response(int sock, char *buffer, size_t buffer_len, stru INFOF("Failed HTTP request: server returned %03u %s", parts->code, parts->reason); return -1; } - if (parts->content_length == -1) { + if (parts->content_length == HTTP_RESPONSE_CONTENT_LENGTH_UNSET) { if (config.debug.rhizome_rx) DEBUGF("Invalid HTTP reply: missing Content-Length header"); return -1; diff --git a/rhizome_fetch.c b/rhizome_fetch.c index a7573f0f..6627ed9d 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -1541,7 +1541,7 @@ void rhizome_fetch_poll(struct sched_ent *alarm) rhizome_fetch_switch_to_mdp(slot); return; } - if (parts.content_length == -1) { + if (parts.content_length == HTTP_RESPONSE_CONTENT_LENGTH_UNSET) { if (config.debug.rhizome_rx) DEBUGF("Invalid HTTP reply: missing Content-Length header"); rhizome_fetch_switch_to_mdp(slot); @@ -1619,7 +1619,7 @@ int unpack_http_response(char *response, struct http_response_parts *parts) parts->code = 0; parts->reason = NULL; parts->range_start=0; - parts->content_length = -1; + parts->content_length = HTTP_RESPONSE_CONTENT_LENGTH_UNSET; parts->content_start = NULL; char *p = NULL; if (!str_startswith(response, "HTTP/1.0 ", (const char **)&p)) {