diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2014-03-20 10:22:41 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2014-03-21 22:29:26 +0100 |
commit | 0b79979bb9dde5fd8bc2ef72431e5ce2a5439a3f (patch) | |
tree | babd7e9146a3367f9fa1704ad0683817d8a9e951 /daemons/clvmd/clvmd.c | |
parent | f8cd435cd83140e26d35e17f6fbccc1019f67aed (diff) | |
download | lvm2-0b79979bb9dde5fd8bc2ef72431e5ce2a5439a3f.tar.gz |
cleanup: clvmd dump_messages
Diffstat (limited to 'daemons/clvmd/clvmd.c')
-rw-r--r-- | daemons/clvmd/clvmd.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index bc831d01c..a21d53a70 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -1120,30 +1120,27 @@ static int verify_message(char *buf, int len) static void dump_message(char *buf, int len) { - unsigned char row[8] = { 0 }; + unsigned char row[8]; char str[9]; - int i, j, pos = 0; + int i, j = 0; + str[8] = '\0'; if (len > 128) len = 128; - for (i = 0; i < len; i++) { - row[pos++] = buf[i]; + for (i = 0; i < len; ++i) { + row[j] = buf[i]; + str[j] = (isprint(buf[i])) ? buf[i] : ' '; - if ((pos == 8) || (i + 1 == len)) { - memset(str, 0, sizeof(str)); - - for (j = 0; j < 8; j++) { - if (isprint(row[j])) - str[j] = row[j]; - else - str[j] = ' '; + if ((j == 8) || (i + 1 == len)) { + for (;j < 8; ++j) { + row[j] = 0; + str[j] = ' '; } log_error("%02x %02x %02x %02x %02x %02x %02x %02x [%s]", row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], str); - pos = 0; - memset(row, 0, sizeof(row)); + j = 0; } } } |