doh: minor edits to please Coverity
authorDaniel Stenberg <daniel@haxx.se>
Fri, 7 Sep 2018 07:26:08 +0000 (09:26 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 7 Sep 2018 07:26:08 +0000 (09:26 +0200)
The gcc typecheck macros and coverity combined made it warn on the 2nd
argument for ERROR_CHECK_SETOPT(). Here's minor rearrange to please it.

Coverity CID 1439115 and CID 1439114.

lib/doh.c

index 33b3e06c9164873bfc7990a273cd77bb42877406..70ffede358c99cae24653fc964d0cc63e3fce414 100644 (file)
--- a/lib/doh.c
+++ b/lib/doh.c
@@ -218,11 +218,14 @@ static CURLcode dohprobe(struct Curl_easy *data,
   /* Curl_open() is the internal version of curl_easy_init() */
   result = Curl_open(&doh);
   if(!result) {
+    /* pass in the struct pointer via a local variable to please coverity and
+       the gcc typecheck helpers */
+    struct dohresponse *resp = &p->serverdoh;
     ERROR_CHECK_SETOPT(CURLOPT_URL, url);
     ERROR_CHECK_SETOPT(CURLOPT_WRITEFUNCTION, doh_write_cb);
-    ERROR_CHECK_SETOPT(CURLOPT_WRITEDATA, (void *)&p->serverdoh);
+    ERROR_CHECK_SETOPT(CURLOPT_WRITEDATA, resp);
     if(!data->set.doh_get) {
-      ERROR_CHECK_SETOPT(CURLOPT_POSTFIELDS, &p->dohbuffer[0]);
+      ERROR_CHECK_SETOPT(CURLOPT_POSTFIELDS, p->dohbuffer);
       ERROR_CHECK_SETOPT(CURLOPT_POSTFIELDSIZE, p->dohlen);
     }
     ERROR_CHECK_SETOPT(CURLOPT_HTTPHEADER, headers);