Handle return values from fchown

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.
This commit is contained in:
Jeff Kowalski 2016-03-12 11:21:52 -08:00
parent 540bdfcb02
commit 46b9f263ac
2 changed files with 9 additions and 5 deletions

View File

@ -866,7 +866,8 @@ bool env_universal_t::sync(callback_data_list_t *callbacks)
struct stat sbuf;
if (wstat(vars_path, &sbuf) >= 0)
{
fchown(private_fd, sbuf.st_uid, sbuf.st_gid);
if (0 > fchown(private_fd, sbuf.st_uid, sbuf.st_gid))
UNIVERSAL_LOG("fchown() failed");
fchmod(private_fd, sbuf.st_mode);
}

View File

@ -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);
}