From: Hongchao Zhang Date: Wed, 11 Jul 2012 07:20:20 +0000 (+0800) Subject: LU-1436 debug: return the original type in RETURN X-Git-Tag: 2.2.92~1 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=28f99cac5963cb166b103f56feea393ac24cf076 LU-1436 debug: return the original type in RETURN in RETURN, the bit length of rc could be 32 or 64, and it also could be pointer type, the conversion betweens pointer and integer type will trigger compile warning related to type casting, then define an static variable of typeof(rc), and avoid the stack usage ATM. Signed-off-by: Hongchao Zhang Change-Id: I7f3a54438dfe1f294168691718c4db8116f68de4 Reviewed-on: http://review.whamcloud.com/3072 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index 4a97f4f..4306a89 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -300,17 +300,38 @@ do { \ #if defined(__GNUC__) long libcfs_log_return(struct libcfs_debug_msg_data *, long rc); -#define RETURN(rc) \ -do { \ - EXIT_NESTING; \ - if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ - return (typeof(rc))libcfs_log_return(&msgdata, \ - (long)(rc)); \ - } \ - \ - return (rc); \ +#if BITS_PER_LONG > 32 +#define RETURN(rc) \ +do { \ + EXIT_NESTING; \ + if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ + LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ + return (typeof(rc))libcfs_log_return(&msgdata, \ + (long)(rc)); \ + } \ + \ + return (rc); \ } while (0) +#else /* BITS_PER_LONG == 32 */ +/* We need an on-stack variable, because we cannot case a 32-bit pointer + * directly to (long long) without generating a complier warning/error, yet + * casting directly to (long) will truncate 64-bit return values. The log + * values will print as 32-bit values, but they always have been. LU-1436 + */ +#define RETURN(rc) \ +do { \ + EXIT_NESTING; \ + if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ + typeof(rc) __rc = (rc); \ + LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ + libcfs_log_return(&msgdata, (long_ptr_t)__rc); \ + return __rc; \ + } \ + \ + return (rc); \ +} while (0) +#endif /* BITS_PER_LONG > 32 */ + #elif defined(_MSC_VER) #define RETURN(rc) \ do { \