aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-03-07 01:44:45 -0500
committerMike Frysinger <vapier@gentoo.org>2009-03-07 01:44:45 -0500
commit31e552065c41abbba77cf92717533c5d8f2a98e0 (patch)
treef9fcf1952ff2e034c4f42fb8952a02651cee28e5 /libsandbox/wrapper-funcs
parentadd a test case for previous commit (diff)
downloadsandbox-31e552065c41abbba77cf92717533c5d8f2a98e0.tar.gz
sandbox-31e552065c41abbba77cf92717533c5d8f2a98e0.tar.bz2
sandbox-31e552065c41abbba77cf92717533c5d8f2a98e0.zip
libsandbox: push errno save/restore down in openat()
Minor optimization to not bother saving/restoring the errno if we don't actually call another C library function. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox/wrapper-funcs')
-rw-r--r--libsandbox/wrapper-funcs/__openat_2.c10
-rw-r--r--libsandbox/wrapper-funcs/openat.c10
2 files changed, 10 insertions, 10 deletions
diff --git a/libsandbox/wrapper-funcs/__openat_2.c b/libsandbox/wrapper-funcs/__openat_2.c
index 3384b93..fd13714 100644
--- a/libsandbox/wrapper-funcs/__openat_2.c
+++ b/libsandbox/wrapper-funcs/__openat_2.c
@@ -21,20 +21,20 @@
static inline bool PRE_CHECK_FUNC(WRAPPER_NAME)(WRAPPER_ARGS_PROTO)
{
if (!(flags & O_CREAT)) {
- save_errno();
-
/* If we're not trying to create, fail normally if
* file does not stat
*/
- struct stat st;
#if USE_AT
if (dirfd == AT_FDCWD || pathname[0] == '/')
#endif
#undef USE_AT
+ {
+ struct stat st;
+ save_errno();
if (-1 == stat(pathname, &st))
return false;
-
- restore_errno();
+ restore_errno();
+ }
}
return true;
diff --git a/libsandbox/wrapper-funcs/openat.c b/libsandbox/wrapper-funcs/openat.c
index 9468515..2855464 100644
--- a/libsandbox/wrapper-funcs/openat.c
+++ b/libsandbox/wrapper-funcs/openat.c
@@ -25,20 +25,20 @@
static inline bool PRE_CHECK_FUNC(WRAPPER_NAME)(_WRAPPER_ARGS_PROTO)
{
if (!(flags & O_CREAT)) {
- save_errno();
-
/* If we're not trying to create, fail normally if
* file does not stat
*/
- struct stat st;
#if USE_AT
if (dirfd == AT_FDCWD || pathname[0] == '/')
#endif
#undef USE_AT
+ {
+ struct stat st;
+ save_errno();
if (-1 == stat(pathname, &st))
return false;
-
- restore_errno();
+ restore_errno();
+ }
}
return true;