Fix unused results warnings
authorFlorian Fainelli <f.fainelli@gmail.com>
Thu, 8 Dec 2016 03:04:45 +0000 (19:04 -0800)
committerFelix Fietkau <nbd@nbd.name>
Fri, 9 Dec 2016 12:06:06 +0000 (13:06 +0100)
Fixes:

uclient-http.c:385:8: error: ignoring return value of 'fread', declared with attribute warn_unused_result [-Werror=unused-result]
   fread(&val, sizeof(val), 1, f);
        ^

uclient-fetch.c: In function 'main':
uclient-fetch.c:664:12: error: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Werror=unused-result]
    asprintf(&auth_str, "%s:%s", username, password);
            ^
uclient-fetch.c: In function 'read_data_cb':
uclient-fetch.c:269:9: error: ignoring return value of 'write', declared with attribute warn_unused_result [-Werror=unused-result]
    write(output_fd, buf, len);

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
uclient-fetch.c
uclient-http.c

index 4c603fbc19452d3210d03e3d9745dd9a3fcdc2c0..d9582f55e2c1d46b78886ba22d2244be523f4554 100644 (file)
@@ -254,6 +254,7 @@ static void header_done_cb(struct uclient *cl)
 static void read_data_cb(struct uclient *cl)
 {
        char buf[256];
+       ssize_t n;
        int len;
 
        if (!no_output && output_fd < 0)
@@ -265,8 +266,11 @@ static void read_data_cb(struct uclient *cl)
                        return;
 
                out_bytes += len;
-               if (!no_output)
-                       write(output_fd, buf, len);
+               if (!no_output) {
+                       n = write(output_fd, buf, len);
+                       if (n < 0)
+                               return;
+               }
        }
 }
 
@@ -660,9 +664,11 @@ int main(int argc, char **argv)
        uloop_init();
 
        if (username) {
-               if (password)
-                       asprintf(&auth_str, "%s:%s", username, password);
-               else
+               if (password) {
+                       rc = asprintf(&auth_str, "%s:%s", username, password);
+                       if (rc < 0)
+                               return rc;
+               } else
                        auth_str = username;
        }
 
index 8d26bd4884be11d06b8c7913ad31f159eaa60c3a..ac9d50f4b2ad914590bf6517f4fe90b181f7425a 100644 (file)
@@ -379,11 +379,14 @@ get_cnonce(char *dest)
 {
        uint32_t val = 0;
        FILE *f;
+       size_t n;
 
        f = fopen("/dev/urandom", "r");
        if (f) {
-               fread(&val, sizeof(val), 1, f);
+               n = fread(&val, sizeof(val), 1, f);
                fclose(f);
+               if (n != 1)
+                       return;
        }
 
        bin_to_hex(dest, &val, sizeof(val));