#define dendl std::endl; _dout_end_line(); } } while (0)
-inline static void hexdump(string msg, const char *s, int len)
+inline static void hex2str(const char *s, int len, char *buf, int dest_len)
{
- int buf_len = len*4;
- char buf[buf_len];
int pos = 0;
- for (int i=0; i<len && pos<buf_len - 8; i++) {
+ for (int i=0; i<len && pos<dest_len; i++) {
if (i && !(i%8))
- pos += snprintf(&buf[pos], buf_len-pos, " ");
+ pos += snprintf(&buf[pos], dest_len-pos, " ");
if (i && !(i%16))
- pos += snprintf(&buf[pos], buf_len-pos, "\n");
- pos += snprintf(&buf[pos], buf_len-pos, "%.2x ", (int)(unsigned char)s[i]);
+ pos += snprintf(&buf[pos], dest_len-pos, "\n");
+ pos += snprintf(&buf[pos], dest_len-pos, "%.2x ", (int)(unsigned char)s[i]);
}
+}
+
+inline static void hexdump(string msg, const char *s, int len)
+{
+ int buf_len = len*4;
+ char buf[buf_len];
+ hex2str(s, len, buf, buf_len);
generic_dout(0) << msg << ":\n" << buf << dendl;
}