Re: [PATCH RESEND 2/3] kmsg: export printk records to the /dev/kmsginterface

From: Dan Carpenter
Date: Thu May 10 2012 - 07:42:00 EST


On Thu, May 03, 2012 at 02:29:41AM +0200, Kay Sievers wrote:
> + /* escape non-printable characters */
> + for (i = 0; i < msg->text_len; i++) {
> + char c = log_text(msg)[i];
> +
> + if (c < ' ' || c >= 128)

Signed char type is never larger than 127.

> + len += sprintf(user->buf + len, "\\x%02x", c);
> + else
> + user->buf[len++] = c;
> + }
> + user->buf[len++] = '\n';
> +
> + if (msg->dict_len) {
> + bool line = true;
> +
> + for (i = 0; i < msg->dict_len; i++) {
> + char c = log_dict(msg)[i];
> +
> + if (line) {
> + user->buf[len++] = ' ';
> + line = false;
> + }
> +
> + if (c == '\0') {
> + user->buf[len++] = '\n';
> + line = true;
> + continue;
> + }
> +
> + if (c < ' ' || c >= 128) {

Same.

> + len += sprintf(user->buf + len, "\\x%02x", c);
> + continue;
> + }
> +

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/