diff --git a/src/main.c b/src/main.c
index 82deedf..1404281 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3330,11 +3330,18 @@ static size_t my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
   struct OutStruct *out=(struct OutStruct *)stream;
   struct Configurable *config = out->config;
 
+  /*
+   * 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.
+   */
+  const size_t err_rc = (sz * nmemb) ? 0 : 1;
+
   if(!out->stream) {
-    const size_t rv = (sz * nmemb) ? 1 : 0;
     if (!out->filename) {
       warnf(config, "Remote filename has no length!\n");
-      return rv; /* Failure */
+      return err_rc; /* Failure */
     }
 
     if (config->content_disposition) {
@@ -3344,7 +3351,7 @@ static size_t my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
         fclose(f);
         warnf(config, "Refusing to overwrite %s: %s\n", out->filename,
               strerror(EEXIST));
-        return rv; /* Failure */
+        return err_rc; /* Failure */
       }
     }
 
@@ -3353,15 +3360,7 @@ static size_t my_fwrite(void *buffer, size_t sz, size_t nmemb, void *stream)
     if(!out->stream) {
       warnf(config, "Failed to create the file %s: %s\n", out->filename,
             strerror(errno));
-
-      /*
-       * 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 */
+      return err_rc; /* failure */
     }
   }
 
@@ -4087,6 +4086,7 @@ parse_filename(char *ptr, int len)
   char* q;
   char quote = 0;
 
+  /* simple implementation of strndup() */
   copy = malloc(len+1);
   if (!copy)
     return NULL;
@@ -4138,7 +4138,7 @@ header_callback(void *ptr, size_t size, size_t nmemb, void *stream)
 
       while (p < end && !isalpha(*p))
         p++;
-      if (p == end || p > end-9)
+      if (p > end-9)
         break;
 
       if (memcmp(p, "filename=", 9)) {
@@ -5173,9 +5173,8 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
             break;
           }
 
-          if (config->content_disposition && outs.stream)
-            if (!config->mute)
-              printf("curl: Saved to filename '%s'\n", outs.filename);
+          if (config->content_disposition && outs.stream && !config->mute)
+            printf("curl: Saved to filename '%s'\n", outs.filename);
 
           /* if retry-max-time is non-zero, make sure we haven't exceeded the
              time */

