summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2017-10-11 17:06:40 -0400
committerColin Walters <walters@verbum.org>2017-10-11 17:07:54 -0400
commite627524af9ae499c1edd04795442f8bdb05b5223 (patch)
treedac4e076249fe49e654996113d608fa46abe6814
parentb923a950af1b3cfc4ba1fc877428928ffd4f38ec (diff)
downloadlibglnx-e627524af9ae499c1edd04795442f8bdb05b5223.tar.gz
fdio: Avoid ?: syntax for fstatat_allow_noent()
`g-ir-scanner` is unaware of this GNUC extension and complains. Saw that while building ostree. While we're here, fix up a few other things: - Tell the compiler the stat buffer is unused (I didn't see a warning, just doing this on general principle) - Return from `glnx_throw_errno_prefix()` directly; we do preserve errno there, let's feel free to rely on it.
-rw-r--r--glnx-fdio.h12
1 files changed, 4 insertions, 8 deletions
diff --git a/glnx-fdio.h b/glnx-fdio.h
index 1aa0c43..dc93b68 100644
--- a/glnx-fdio.h
+++ b/glnx-fdio.h
@@ -318,16 +318,12 @@ glnx_fstatat_allow_noent (int dfd,
int flags,
GError **error)
{
- struct stat stbuf;
- if (TEMP_FAILURE_RETRY (fstatat (dfd, path, out_buf ?: &stbuf, flags)) != 0)
+ G_GNUC_UNUSED struct stat unused_stbuf;
+ if (TEMP_FAILURE_RETRY (fstatat (dfd, path, out_buf ? out_buf : &unused_stbuf, flags)) != 0)
{
if (errno != ENOENT)
- {
- int errsv = errno;
- (void) glnx_throw_errno_prefix (error, "fstatat(%s)", path);
- errno = errsv;
- return FALSE;
- }
+ return glnx_throw_errno_prefix (error, "fstatat(%s)", path);
+ /* Note we preserve errno as ENOENT */
}
else
errno = 0;