All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Josh Triplett <josh@joshtriplett.org>
Cc: Yinghai Lu <yinghai@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	Vivek Goyal <vgoyal@redhat.com>,
	Junjie Mao <eternal.n08@gmail.com>,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH v2] x86, boot: add hex output for debugging
Date: Fri, 31 Oct 2014 17:03:21 -0700	[thread overview]
Message-ID: <1414800201.13647.9.camel@perches.com> (raw)
In-Reply-To: <20141031234531.GA12082@thin>

On Fri, 2014-10-31 at 16:45 -0700, Josh Triplett wrote:
> I don't think we need the full generality of printf in the decompression
> stub.  I prefer Kees' patch, though I'd still like to see __puthex made
> conditional.

Maybe use a statement expression macro instead?
Something like this could emit the right number of bits for any type

#define __puthex(val)							\
({									\
	typeof(val) value = val;					\
	char alpha[2] = {};						\
	int bits;							\
									\
	__putstr("0x");							\
	for (bits = sizeof(value) * 8 - 4; bits >= 0; bits -= 4) {	\
		int digit = (value >> bits) & 0xf;			\
									\
		if (digit < 10)						\
			alpha[0] = '0' + digit;				\
		else							\
			alpha[0] = 'a' + (digit - 10);			\
									\
		__putstr(alpha);					\
	}								\
})



      reply	other threads:[~2014-11-01  0:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-31 20:58 [PATCH v2] x86, boot: add hex output for debugging Kees Cook
2014-10-31 21:34 ` Andy Lutomirski
2014-10-31 23:31 ` Yinghai Lu
2014-10-31 23:45   ` Josh Triplett
2014-11-01  0:03     ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1414800201.13647.9.camel@perches.com \
    --to=joe@perches.com \
    --cc=ak@linux.intel.com \
    --cc=eternal.n08@gmail.com \
    --cc=hpa@zytor.com \
    --cc=josh@joshtriplett.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vgoyal@redhat.com \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.