Skip to contentSkip to conversation

fix syncfs handling in error case

PATCH Applied Danny Al-Gaaf 2 participants 2 messages Nov 27, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix syncfs handling in error case

If the call to syncfs() fails, don't try to call syncfs again via syscall(). If HAVE_SYS_SYNCFS is defined, don't fall through to try syscall() with SYS_syncfs or __NR_syncfs.

---
 src/common/sync_filesystem.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
src/common/sync_filesystem.h +2 -6
index 5b23576..eff18d2 100644
@@ -34,14 +34,10 @@ inline int sync_filesystem(int fd)
 #ifdef HAVE_SYS_SYNCFS
   if (syncfs(fd) == 0)
     return 0;
-#endif
-
-#ifdef SYS_syncfs
+#elif defined(SYS_syncfs)
   if (syscall(SYS_syncfs, fd) == 0)
     return 0;
-#endif
-
-#ifdef __NR_syncfs
+#elif defined(__NR_syncfs)
   if (syscall(__NR_syncfs, fd) == 0)
     return 0;
 #endif
Signature · 1 line
1.8.0
Applied
#1 lore raw

Applied, thanks!

sage

Quoted 34 lines · Danny Al-Gaaf

If the call to syncfs() fails, don't try to call syncfs again via syscall(). If HAVE_SYS_SYNCFS is defined, don't fall through to try syscall() with SYS_syncfs or __NR_syncfs.

---
 src/common/sync_filesystem.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
src/common/sync_filesystem.h +2 -6
index 5b23576..eff18d2 100644
@@ -34,14 +34,10 @@ inline int sync_filesystem(int fd)
 #ifdef HAVE_SYS_SYNCFS
   if (syncfs(fd) == 0)
     return 0;
-#endif
-
-#ifdef SYS_syncfs
+#elif defined(SYS_syncfs)
   if (syscall(SYS_syncfs, fd) == 0)
     return 0;
-#endif
-
-#ifdef __NR_syncfs
+#elif defined(__NR_syncfs)
   if (syscall(__NR_syncfs, fd) == 0)
     return 0;
 #endif
Signature · 1 line
1.8.0