From: Cary Coutant Date: Sat, 24 Mar 2018 06:33:47 +0000 (-0700) Subject: Fix warn-unused-return message. X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=8da9a904f41bb78fca5568fb94004120682b1653;p=deliverable%2Fbinutils-gdb.git Fix warn-unused-return message. gold/ * plugin.cc (link_or_copy_file): Remove newlines from warning messages. Add pedantic check for return value from ::write. --- diff --git a/gold/ChangeLog b/gold/ChangeLog index f0f0d5c68d..7364a63bd7 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,8 @@ +2018-03-23 Cary Coutant + + * plugin.cc (link_or_copy_file): Remove newlines from warning messages. + Add pedantic check for return value from ::write. + 2018-03-23 Cary Coutant * debug.h (DEBUG_PLUGIN): New constant. diff --git a/gold/plugin.cc b/gold/plugin.cc index b12a7a9fae..c921f7ca3d 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -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(::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;