Signed-off-by: Zeng Linggang <[email protected]>
---
 include/safe_macros.h |  5 +++++
 lib/safe_macros.c     | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/safe_macros.h b/include/safe_macros.h
index adf4d09..1a6acdd 100644
--- a/include/safe_macros.h
+++ b/include/safe_macros.h
@@ -175,5 +175,10 @@ long safe_sysconf(const char *file, const int lineno,
 #define SAFE_SYSCONF(cleanup_fn, name) \
        safe_sysconf(__FILE__, __LINE__, cleanup_fn, name)
 
+int safe_fstat(const char *file, const int lineno, void (cleanup_fn)(void),
+              int fd, struct stat *buf);
+#define SAFE_FSTAT(cleanup_fn, fd, buf) \
+       safe_fstat(__FILE__, __LINE__, (cleanup_fn), (fd), (buf))
+
 #endif /* __SAFE_MACROS_H__ */
 #endif /* __TEST_H__ */
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index 4da9914..dea8241 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -438,3 +438,18 @@ long safe_sysconf(const char *file, const int lineno,
 
        return rval;
 }
+
+int safe_fstat(const char *file, const int lineno,
+              void (cleanup_fn)(void), int fd, struct stat *buf)
+{
+       int rval;
+
+       rval = fstat(fd, buf);
+
+       if (rval == -1) {
+               tst_brkm(TBROK | TERRNO, cleanup_fn,
+                        "fstat  failed at %s:%d", file, lineno);
+       }
+
+       return rval;
+}
-- 
1.8.2.1





------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to