Fix warn-unused-return message.
authorCary Coutant <ccoutant@gmail.com>
Sat, 24 Mar 2018 06:33:47 +0000 (23:33 -0700)
committerCary Coutant <ccoutant@gmail.com>
Sat, 24 Mar 2018 06:34:13 +0000 (23:34 -0700)
gold/
* plugin.cc (link_or_copy_file): Remove newlines from warning messages.
Add pedantic check for return value from ::write.

gold/ChangeLog
gold/plugin.cc

index f0f0d5c68da2ea13284e2478e3f2e7a218735e68..7364a63bd7d92a75872b3ae5425e431c23630f72 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-23  Cary Coutant  <ccoutant@gmail.com>
+
+       * plugin.cc (link_or_copy_file): Remove newlines from warning messages.
+       Add pedantic check for return value from ::write.
+
 2018-03-23  Cary Coutant  <ccoutant@gmail.com>
 
        * debug.h (DEBUG_PLUGIN): New constant.
index b12a7a9fae7fce2d076c3cdcb6730bdadd3aaed8..c921f7ca3d210bbd52d5f54eae7343e631062005 100644 (file)
@@ -568,19 +568,26 @@ link_or_copy_file(const char* inname, const char* outname)
   int in = ::open(inname, O_RDONLY);
   if (in < 0)
     {
-      gold_warning(_("%s: can't open (%s)\n"), inname, strerror(errno));
+      gold_warning(_("%s: can't open (%s)"), inname, strerror(errno));
       return false;
     }
   int out = ::open(outname, O_CREAT | O_TRUNC | O_WRONLY, 0600);
   if (out < 0)
     {
-      gold_warning(_("%s: can't create (%s)\n"), outname, strerror(errno));
+      gold_warning(_("%s: can't create (%s)"), outname, strerror(errno));
       ::close(in);
       return false;
     }
   ssize_t len;
   while ((len = ::read(in, buf, sizeof(buf))) > 0)
-    static_cast<void>(::write(out, buf, len));
+    {
+      if (::write(out, buf, len) != len)
+       {
+         gold_warning(_("%s: write error while making copy of file (%s)"),
+                      inname, strerror(errno));
+         break;
+        }
+    }
   ::close(in);
   ::close(out);
   return true;
This page took 0.025442 seconds and 4 git commands to generate.