From 72fc9328b1959f2f3e8b24048995cb70a090e0a3 Mon Sep 17 00:00:00 2001 From: vinayak hegde Date: Fri, 9 Oct 2009 02:38:13 +0000 Subject: debug/trace: Check asprintf return value to avoid warning, while build Signed-off-by: Anand V. Avati BUG: 308 (Warning in debug/trace.c, during build) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=308 --- xlators/debug/trace/src/trace.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index b8075592236..16c12eb963b 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -62,6 +62,7 @@ trace_stat_to_str (struct stat *stbuf) char atime_buf[256] = {0,}; char mtime_buf[256] = {0,}; char ctime_buf[256] = {0,}; + int asprint_ret_value = 0; strftime (atime_buf, 256, "[%b %d %H:%M:%S]", localtime (&stbuf->st_atime)); @@ -70,13 +71,16 @@ trace_stat_to_str (struct stat *stbuf) strftime (ctime_buf, 256, "[%b %d %H:%M:%S]", localtime (&stbuf->st_ctime)); - asprintf (&statstr, - "st_ino=%"PRIu64", st_mode=%o, st_nlink=%"GF_PRI_NLINK", " - "st_uid=%d, st_gid=%d, st_size=%"PRId64", st_blocks=%"PRId64 - ", st_atime=%s, st_mtime=%s, st_ctime=%s", - stbuf->st_ino, stbuf->st_mode, stbuf->st_nlink, stbuf->st_uid, - stbuf->st_gid, stbuf->st_size, stbuf->st_blocks, atime_buf, - mtime_buf, ctime_buf); + asprint_ret_value = asprintf (&statstr, + "st_ino=%"PRIu64", st_mode=%o, st_nlink=%"GF_PRI_NLINK", " + "st_uid=%d, st_gid=%d, st_size=%"PRId64", st_blocks=%"PRId64 + ", st_atime=%s, st_mtime=%s, st_ctime=%s", + stbuf->st_ino, stbuf->st_mode, stbuf->st_nlink, stbuf->st_uid, + stbuf->st_gid, stbuf->st_size, stbuf->st_blocks, atime_buf, + mtime_buf, ctime_buf); + + if (asprint_ret_value < 0) + statstr = NULL; return statstr; } -- cgit