From 46b9f263ac780ae6a921fc24611c75bbec92ebca Mon Sep 17 00:00:00 2001 From: Jeff Kowalski Date: Sat, 12 Mar 2016 11:21:52 -0800 Subject: Handle return values from fchown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function fchown is annotated with warn_unused_result. As formerly used in the code, it would emit a compiler warning ```warning: ignoring return value of ‘fchown’, declared with attribute warn_unused_result [-Wunused-result]``` This commit notes the return value and emits appropriate error/logging messages if the call fails, creating more traceable results and satisfying the compiler. --- src/history.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/history.cpp') diff --git a/src/history.cpp b/src/history.cpp index 1bada96d..022524c3 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1453,7 +1453,10 @@ bool history_t::save_internal_via_rewrite() if (wstat(new_name, &sbuf) >= 0) { /* Success */ - fchown(out_fd, sbuf.st_uid, sbuf.st_gid); + if (0 > fchown(out_fd, sbuf.st_uid, sbuf.st_gid)) + { + debug(2, L"Error when changing ownership of history file"); + } fchmod(out_fd, sbuf.st_mode); } -- cgit v1.2.3