diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2011-02-12 12:46:00 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2011-02-12 12:46:00 +0000 |
commit | 49e51fb02ca0e1b771c7cad859620fce89e4c4c4 (patch) | |
tree | 1f4a6dfe93b8c208a51d4e5ac609046e0248ac43 /lib | |
parent | a7c797f063af407a2a87163d39e8b84788bd91a1 (diff) | |
download | src-49e51fb02ca0e1b771c7cad859620fce89e4c4c4.tar.gz src-49e51fb02ca0e1b771c7cad859620fce89e4c4c4.zip |
Replace ERROR() macro with inline function. In-tree gcc cannot tolerate
the construct like printf("%\s", NULL) resulting from macroexpand of
ERROR(u, NULL), making it impossible to use LIBUFS_DEBUGGING.
With inline function, compiler cannot detect the NULL argument to
known function and does not try to convert it into puts().
In collaboration with: pho
Notes
Notes:
svn path=/head/; revision=218601
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libufs/libufs.h | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/lib/libufs/libufs.h b/lib/libufs/libufs.h index c3541a0c8e6b..a16d82b604ad 100644 --- a/lib/libufs/libufs.h +++ b/lib/libufs/libufs.h @@ -31,34 +31,6 @@ #define __LIBUFS_H__ /* - * libufs macros (internal, non-exported). - */ -#ifdef _LIBUFS -#ifdef _LIBUFS_DEBUGGING -/* - * Trace steps through libufs, to be used at entry and erroneous return. - */ -#define ERROR(uufsd, str) \ -do { \ - fprintf(stderr, "libufs in %s", __func__); \ - if (str != NULL) \ - fprintf(stderr, ": %s", str); \ - if (errno) \ - fprintf(stderr, ": %s", strerror(errno)); \ - fprintf(stderr, "\n"); \ - if ((uufsd) != NULL) \ - (uufsd)->d_error = str; \ -} while (0) -#else /* _LIBUFS_DEBUGGING */ -#define ERROR(uufsd, str) \ -do { \ - if ((uufsd) != NULL) \ - (uufsd)->d_error = str; \ -} while (0) -#endif /* _LIBUFS_DEBUGGING */ -#endif /* _LIBUFS */ - -/* * libufs structures. */ @@ -94,6 +66,30 @@ struct uufsd { #define d_cg d_cgunion.d_cg }; +/* + * libufs macros (internal, non-exported). + */ +#ifdef _LIBUFS +/* + * Trace steps through libufs, to be used at entry and erroneous return. + */ +static inline void +ERROR(struct uufsd *u, const char *str) +{ + +#ifdef _LIBUFS_DEBUGGING + if (str != NULL) { + fprintf(stderr, "libufs: %s", str); + if (errno != 0) + fprintf(stderr, ": %s", strerror(errno)); + fprintf(stderr, "\n"); + } +#endif + if (u != NULL) + u->d_error = str; +} +#endif /* _LIBUFS */ + __BEGIN_DECLS /* |