diff options
author | Cary Coutant <ccoutant@gmail.com> | 2018-03-23 23:33:47 -0700 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2018-03-23 23:34:13 -0700 |
commit | 8da9a904f41bb78fca5568fb94004120682b1653 (patch) | |
tree | 497425f9979ff7501055abafd42b20bc2dbe5fd1 /gold | |
parent | 3215deaaa6abbb7663fa3ec13a03ad74fd58b705 (diff) | |
download | gdb-8da9a904f41bb78fca5568fb94004120682b1653.zip gdb-8da9a904f41bb78fca5568fb94004120682b1653.tar.gz gdb-8da9a904f41bb78fca5568fb94004120682b1653.tar.bz2 |
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.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 5 | ||||
-rw-r--r-- | gold/plugin.cc | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index f0f0d5c..7364a63 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,5 +1,10 @@ 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. (DEBUG_ALL): Add DEBUG_PLUGIN. (debug_string_to_enum): Likewise. diff --git a/gold/plugin.cc b/gold/plugin.cc index b12a7a9..c921f7c 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<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; |