chiark / gitweb /
Check return value of read(2)
authorMatthew Vernon <matthew@debian.org>
Fri, 7 Nov 2025 11:43:15 +0000 (11:43 +0000)
committerMatthew Vernon <matthew@debian.org>
Fri, 7 Nov 2025 14:35:30 +0000 (14:35 +0000)
Again, picked up by newer tooling.

squish.c:648:25: error: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]

squish.c

index 91c866ea8783dab39ebdb62756dd7c077db11bc0..2c1607a1d365873461221532bfc251433c5b8001 100644 (file)
--- a/squish.c
+++ b/squish.c
@@ -645,7 +645,9 @@ int main(int argc,char **argv)
                        fprintf(stderr, " do you wish to overwrite %s (y or n)? ",
                        ofname);
                        fflush(stderr);
-                       read(2, response, 2);
+                       if (read(2, response, 2) < 1) {
+                         perror("stderr"); break;
+                       }
                        while (response[1] != '\n') {
                            if (read(2, response+1, 1) < 0) {   /* Ack! */
                                perror("stderr"); break;