2009-09-01 Jim Meyering <meyering@redhat.com>
+ fts: help ensure that return values are not ignored
+ * lib/fts_.h (__GNUC_PREREQ): Define.
+ (__attribute_warn_unused_result__): Define.
+ (fts_children, fts_close, fts_open, fts_read): Declare with
+ __attribute_warn_unused_result__.
+
fts: fts_close now fails also when closing a dir file descriptor fails
* lib/fts.c (fts_close): Detect close failure, not just fchdir failure,
and propagate to caller, along with errno.
char fts_name[1]; /* file name */
} FTSENT;
+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+# else
+# define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
+#if __GNUC_PREREQ (3,4)
+# undef __attribute_warn_unused_result__
+# define __attribute_warn_unused_result__ \
+ __attribute__ ((__warn_unused_result__))
+#else
+# define __attribute_warn_unused_result__ /* empty */
+#endif
+
__BEGIN_DECLS
-FTSENT *fts_children (FTS *, int) __THROW;
-int fts_close (FTS *) __THROW;
+FTSENT *fts_children (FTS *, int) __THROW __attribute_warn_unused_result__;
+int fts_close (FTS *) __THROW __attribute_warn_unused_result__;
FTS *fts_open (char * const *, int,
- int (*)(const FTSENT **, const FTSENT **)) __THROW;
-FTSENT *fts_read (FTS *) __THROW;
+ int (*)(const FTSENT **, const FTSENT **))
+ __THROW __attribute_warn_unused_result__;
+FTSENT *fts_read (FTS *) __THROW __attribute_warn_unused_result__;
int fts_set (FTS *, FTSENT *, int) __THROW;
__END_DECLS