Document switch fall-through cases
[fio.git] / engines / http.c
index f3dfab38fecc453ae35edd2d2e26ce347607f118..a35c03327ec1f2751711ab73f64a5b42113e65e4 100644 (file)
@@ -263,14 +263,27 @@ static char *_gen_hex_md5(const char *p, size_t len)
 }
 
 static void _hmac(unsigned char *md, void *key, int key_len, char *data) {
+#ifndef CONFIG_HAVE_OPAQUE_HMAC_CTX
+       HMAC_CTX _ctx;
+#endif
        HMAC_CTX *ctx;
        unsigned int hmac_len;
 
+#ifdef CONFIG_HAVE_OPAQUE_HMAC_CTX
        ctx = HMAC_CTX_new();
+#else
+       ctx = &_ctx;
+       /* work-around crash in certain versions of libssl */
+       HMAC_CTX_init(ctx);
+#endif
        HMAC_Init_ex(ctx, key, key_len, EVP_sha256(), NULL);
        HMAC_Update(ctx, (unsigned char*)data, strlen(data));
        HMAC_Final(ctx, md, &hmac_len);
+#ifdef CONFIG_HAVE_OPAQUE_HMAC_CTX
        HMAC_CTX_free(ctx);
+#else
+       HMAC_CTX_cleanup(ctx);
+#endif
 }
 
 static int _curl_trace(CURL *handle, curl_infotype type,
@@ -283,9 +296,11 @@ static int _curl_trace(CURL *handle, curl_infotype type,
 
        switch (type) {
        case CURLINFO_TEXT:
-       fprintf(stderr, "== Info: %s", data);
+               fprintf(stderr, "== Info: %s", data);
+               /* fall through */
        default:
        case CURLINFO_SSL_DATA_OUT:
+               /* fall through */
        case CURLINFO_SSL_DATA_IN:
                return 0;
 
@@ -535,7 +550,7 @@ static enum fio_q_status fio_http_queue(struct thread_data *td,
        } else if (io_u->ddir == DDIR_TRIM) {
                curl_easy_setopt(http->curl, CURLOPT_HTTPGET, 1L);
                curl_easy_setopt(http->curl, CURLOPT_CUSTOMREQUEST, "DELETE");
-               curl_easy_setopt(http->curl, CURLOPT_INFILESIZE_LARGE, 0);
+               curl_easy_setopt(http->curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)0);
                curl_easy_setopt(http->curl, CURLOPT_READDATA, NULL);
                curl_easy_setopt(http->curl, CURLOPT_WRITEDATA, NULL);
                res = curl_easy_perform(http->curl);
@@ -575,7 +590,7 @@ static int fio_http_setup(struct thread_data *td)
 {
        struct http_data *http = NULL;
        struct http_options *o = td->eo;
-       int r;
+
        /* allocate engine specific structure to deal with libhttp. */
        http = calloc(1, sizeof(*http));
        if (!http) {
@@ -597,7 +612,7 @@ static int fio_http_setup(struct thread_data *td)
        }
        curl_easy_setopt(http->curl, CURLOPT_READFUNCTION, _http_read);
        curl_easy_setopt(http->curl, CURLOPT_WRITEFUNCTION, _http_write);
-       curl_easy_setopt(http->curl, CURLOPT_SEEKFUNCTION, _http_seek);
+       curl_easy_setopt(http->curl, CURLOPT_SEEKFUNCTION, &_http_seek);
        if (o->user && o->pass) {
                curl_easy_setopt(http->curl, CURLOPT_USERNAME, o->user);
                curl_easy_setopt(http->curl, CURLOPT_PASSWORD, o->pass);
@@ -612,7 +627,7 @@ static int fio_http_setup(struct thread_data *td)
        return 0;
 cleanup:
        fio_http_cleanup(td);
-       return r;
+       return 1;
 }
 
 static int fio_http_open(struct thread_data *td, struct fio_file *f)