debug/trace: Fix length issue found in compilation

Change-Id: I1cd7fd6464d0912294009c2293ed70f3f6744930
BUG: 1092196
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/7586
Reviewed-by: Anand Avati <avati@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
Pranith Kumar K 2014-04-29 06:05:46 +05:30 committed by Vijay Bellur
parent d960a4ac74
commit 4963ec017e

View File

@ -17,9 +17,10 @@
* their _cbk functions, which later passes the call to next layer.
* Very helpful translator for debugging.
*/
#define TRACE_STAT_TO_STR(buf, str) trace_stat_to_str (buf, str, sizeof (str))
static inline void
trace_stat_to_str(struct iatt *buf, char *str)
trace_stat_to_str(struct iatt *buf, char *str, size_t len)
{
char atime_buf[256] = {0,};
char mtime_buf[256] = {0,};
@ -40,7 +41,7 @@ trace_stat_to_str(struct iatt *buf, char *str)
strftime (ctime_buf, 256, "[%b %d %H:%M:%S]",
localtime ((time_t *)&ia_time));
snprintf (str, sizeof (str),
snprintf (str, len,
"gfid=%s ino=%"PRIu64", mode=%o, "
"nlink=%"GF_PRI_NLINK", uid=%u, "
"gid=%u, size=%"PRIu64", "
@ -100,9 +101,9 @@ trace_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_CREATE].enabled) {
char string[4096] = {0,};
if (op_ret >= 0) {
trace_stat_to_str (buf, statstr);
trace_stat_to_str (preparent, preparentstr);
trace_stat_to_str (postparent, postparentstr);
TRACE_STAT_TO_STR (buf, statstr);
TRACE_STAT_TO_STR (preparent, preparentstr);
TRACE_STAT_TO_STR (postparent, postparentstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s (op_ret=%d, fd=%p"
@ -173,7 +174,7 @@ trace_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_STAT].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (buf, statstr);
TRACE_STAT_TO_STR (buf, statstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s op_ret=%d buf=%s",
frame->root->unique,
@ -210,7 +211,7 @@ trace_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_READ].enabled) {
char string[4096] = {0,};
if (op_ret >= 0) {
trace_stat_to_str (buf, statstr);
TRACE_STAT_TO_STR (buf, statstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s op_ret=%d buf=%s",
frame->root->unique,
@ -248,8 +249,8 @@ trace_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_WRITE].enabled) {
char string[4096] = {0,};
if (op_ret >= 0) {
trace_stat_to_str (prebuf, preopstr);
trace_stat_to_str (postbuf, postopstr);
TRACE_STAT_TO_STR (prebuf, preopstr);
TRACE_STAT_TO_STR (postbuf, postopstr);
snprintf (string, sizeof (string),
"%"PRId64": (op_ret=%d, "
@ -339,8 +340,8 @@ trace_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_FSYNC].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (prebuf, preopstr);
trace_stat_to_str (postbuf, postopstr);
TRACE_STAT_TO_STR (prebuf, preopstr);
TRACE_STAT_TO_STR (postbuf, postopstr);
snprintf (string, sizeof (string),
"%"PRId64": (op_ret=%d, "
@ -380,8 +381,8 @@ trace_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_SETATTR].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (statpre, preopstr);
trace_stat_to_str (statpost, postopstr);
TRACE_STAT_TO_STR (statpre, preopstr);
TRACE_STAT_TO_STR (statpost, postopstr);
snprintf (string, sizeof (string),
"%"PRId64": (op_ret=%d, "
@ -419,8 +420,8 @@ trace_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_FSETATTR].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (statpre, preopstr);
trace_stat_to_str (statpost, postopstr);
TRACE_STAT_TO_STR (statpre, preopstr);
TRACE_STAT_TO_STR (statpost, postopstr);
snprintf (string, sizeof (string),
"%"PRId64": (op_ret=%d, "
@ -458,8 +459,8 @@ trace_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_UNLINK].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (preparent, preparentstr);
trace_stat_to_str (postparent, postparentstr);
TRACE_STAT_TO_STR (preparent, preparentstr);
TRACE_STAT_TO_STR (postparent, postparentstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s op_ret=%d, "
@ -506,11 +507,11 @@ trace_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_RENAME].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (buf, statstr);
trace_stat_to_str (preoldparent, preoldparentstr);
trace_stat_to_str (postoldparent, postoldparentstr);
trace_stat_to_str (prenewparent, prenewparentstr);
trace_stat_to_str (postnewparent, postnewparentstr);
TRACE_STAT_TO_STR (buf, statstr);
TRACE_STAT_TO_STR (preoldparent, preoldparentstr);
TRACE_STAT_TO_STR (postoldparent, postoldparentstr);
TRACE_STAT_TO_STR (prenewparent, prenewparentstr);
TRACE_STAT_TO_STR (postnewparent, postnewparentstr);
snprintf (string, sizeof (string),
"%"PRId64": (op_ret=%d, "
@ -553,7 +554,7 @@ trace_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_READLINK].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (stbuf, statstr);
TRACE_STAT_TO_STR (stbuf, statstr);
snprintf (string, sizeof (string),
"%"PRId64": (op_ret=%d, op_errno=%d,"
"buf=%s, stbuf = { %s })",
@ -593,8 +594,8 @@ trace_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_LOOKUP].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (buf, statstr);
trace_stat_to_str (postparent, postparentstr);
TRACE_STAT_TO_STR (buf, statstr);
TRACE_STAT_TO_STR (postparent, postparentstr);
/* print buf->ia_gfid instead of inode->gfid,
* since if the inode is not yet linked to the
* inode table (fresh lookup) then null gfid
@ -644,9 +645,9 @@ trace_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_SYMLINK].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (buf, statstr);
trace_stat_to_str (preparent, preparentstr);
trace_stat_to_str (postparent, postparentstr);
TRACE_STAT_TO_STR (buf, statstr);
TRACE_STAT_TO_STR (preparent, preparentstr);
TRACE_STAT_TO_STR (postparent, postparentstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s (op_ret=%d "
@ -688,9 +689,9 @@ trace_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
char string[4096] = {0,};
if (trace_fop_names[GF_FOP_MKNOD].enabled) {
if (op_ret == 0) {
trace_stat_to_str (buf, statstr);
trace_stat_to_str (preparent, preparentstr);
trace_stat_to_str (postparent, postparentstr);
TRACE_STAT_TO_STR (buf, statstr);
TRACE_STAT_TO_STR (preparent, preparentstr);
TRACE_STAT_TO_STR (postparent, postparentstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s (op_ret=%d "
@ -732,9 +733,9 @@ trace_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_MKDIR].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (buf, statstr);
trace_stat_to_str (preparent, preparentstr);
trace_stat_to_str (postparent, postparentstr);
TRACE_STAT_TO_STR (buf, statstr);
TRACE_STAT_TO_STR (preparent, preparentstr);
TRACE_STAT_TO_STR (postparent, postparentstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s (op_ret=%d "
@ -776,9 +777,9 @@ trace_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
char string[4096] = {0,};
if (trace_fop_names[GF_FOP_LINK].enabled) {
if (op_ret == 0) {
trace_stat_to_str (buf, statstr);
trace_stat_to_str (preparent, preparentstr);
trace_stat_to_str (postparent, postparentstr);
TRACE_STAT_TO_STR (buf, statstr);
TRACE_STAT_TO_STR (preparent, preparentstr);
TRACE_STAT_TO_STR (postparent, postparentstr);
snprintf (string, sizeof (string),
"%"PRId64": (op_ret=%d, "
@ -871,8 +872,8 @@ trace_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_RMDIR].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (preparent, preparentstr);
trace_stat_to_str (postparent, postparentstr);
TRACE_STAT_TO_STR (preparent, preparentstr);
TRACE_STAT_TO_STR (postparent, postparentstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s op_ret=%d, "
@ -911,8 +912,8 @@ trace_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_TRUNCATE].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (prebuf, preopstr);
trace_stat_to_str (postbuf, postopstr);
TRACE_STAT_TO_STR (prebuf, preopstr);
TRACE_STAT_TO_STR (postbuf, postopstr);
snprintf (string, sizeof (string),
"%"PRId64": (op_ret=%d, "
@ -1171,8 +1172,8 @@ trace_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_FTRUNCATE].enabled) {
char string[4096] = {0,};
if (op_ret == 0) {
trace_stat_to_str (prebuf, prebufstr);
trace_stat_to_str (postbuf, postbufstr);
TRACE_STAT_TO_STR (prebuf, prebufstr);
TRACE_STAT_TO_STR (postbuf, postbufstr);
snprintf (string, sizeof (string),
"%"PRId64": op_ret=%d, "
@ -1208,7 +1209,7 @@ trace_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (trace_fop_names[GF_FOP_FSTAT].enabled) {
char string[4096] = {0.};
if (op_ret == 0) {
trace_stat_to_str (buf, statstr);
TRACE_STAT_TO_STR (buf, statstr);
snprintf (string, sizeof (string),
"%"PRId64": gfid=%s op_ret=%d "
"buf=%s", frame->root->unique,