X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Fgss%2Ferr_util.c;h=76a172faedbe4dbc2bea24818bbd445723ffd130;hp=376fb597febbe12654f062e8ccd1a2b9d6792944;hb=9a163f389e96f8c3682391f8aa967a48e3daaaf4;hpb=d2d56f38da01001c92a09afc6b52b5acbd9bc13c diff --git a/lustre/utils/gss/err_util.c b/lustre/utils/gss/err_util.c index 376fb59..76a172f 100644 --- a/lustre/utils/gss/err_util.c +++ b/lustre/utils/gss/err_util.c @@ -81,7 +81,8 @@ void printerr(int priority, char *format, ...) strcat(message_buf, "...\n"); goto printit; } - if (message_buf[strlen(message_buf) - 1] == '\n') + buf_used = strlen(message_buf); + if (buf_used > 0 && message_buf[buf_used - 1] == '\n') goto printit; return; printit: @@ -96,22 +97,26 @@ printit: void print_hexl(int pri, unsigned char *cp, int length) { - int i, j, jm; - unsigned char c; - printerr(pri, "length %d\n",length); printerr(pri, "\n"); + print_hex(pri, cp, length); +} + +void print_hex(int pri, unsigned char *cp, int length) +{ + int i, j, jm; + unsigned char c; for (i = 0; i < length; i += 0x10) { - printerr(pri, " %04x: ", (u_int)i); + printerr(pri, " %04x: ", (unsigned int)i); jm = length - i; jm = jm > 16 ? 16 : jm; for (j = 0; j < jm; j++) { if ((j % 2) == 1) - printerr(pri,"%02x ", (u_int)cp[i+j]); + printerr(pri, "%02x ", (unsigned int)cp[i+j]); else - printerr(pri,"%02x", (u_int)cp[i+j]); + printerr(pri, "%02x", (unsigned int)cp[i+j]); } for (; j < 16; j++) { if ((j % 2) == 1)