On Wed, Apr 05, 2017 at 03:04:24PM +0200, Tom G. Christensen wrote:

> Commit 17966c0a added an unguarded use of curl_easy_strerror.
> This adds a guard so it is not used with curl < 7.12.0.
> 
> Signed-off-by: Tom G. Christensen <t...@jupiterrise.com>
> ---
>  http.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/http.c b/http.c
> index a46ab23af..104caaa75 100644
> --- a/http.c
> +++ b/http.c
> @@ -2116,8 +2116,12 @@ static size_t fwrite_sha1_file(char *ptr, size_t 
> eltsize, size_t nmemb,
>               CURLcode c = curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE,
>                                               &slot->http_code);
>               if (c != CURLE_OK)
> +#if LIBCURL_VERSION_NUM >= 0x070c00
>                       die("BUG: curl_easy_getinfo for HTTP code failed: %s",
>                               curl_easy_strerror(c));
> +#else
> +                     die("BUG: curl_easy_getinfo for HTTP code failed");
> +#endif

These kinds of interleaved conditionals make me nervous that we'll get
something wrong (especially without braces, it's not immediately clear
that both sides are a single statement).

I wonder if it would be more readable to do something like:

  #if LIBCURL_VERSION_NUM < 0x070c00
  static const char *curl_easy_strerror(CURL *curl)
  {
        return "[error code unavailable; curl version too old]";
  }
  #endif

Then callers don't have to individually deal with the ifdef. It does
mean that the user sees that kind-of ugly message, but maybe that is a
good thing. They know they need to upgrade curl to see more details.

-Peff

Reply via email to