summaryrefslogtreecommitdiffstats
path: root/xlators/debug
diff options
context:
space:
mode:
authorvinayak hegde <vinayak@gluster.com>2009-10-09 02:38:13 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-09 02:00:37 -0700
commit72fc9328b1959f2f3e8b24048995cb70a090e0a3 (patch)
treee2957263c87db53ed669e46c780c021d26aa22fe /xlators/debug
parentec7c17bc6f54c2a28353d5b099e6501793eed8f8 (diff)
debug/trace: Check asprintf return value to avoid warning, while build
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 308 (Warning in debug/trace.c, during build) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=308
Diffstat (limited to 'xlators/debug')
-rw-r--r--xlators/debug/trace/src/trace.c18
1 files 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;
}