public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: linux@horizon.com
To: vegard.nossum@gmail.com
Cc: linux@horizon.com, linux-kernel@vger.kernel.org
Subject: Re: [RFC] New kernel-message logging API (take 2)
Date: 27 Sep 2007 21:38:22 -0400	[thread overview]
Message-ID: <20070928013822.28348.qmail@science.horizon.com> (raw)
In-Reply-To: <19f34abd0709271418l471cf7b9gf24161190772fac@mail.gmail.com>

> Example: {
>	struct kprint_block out;
>	kprint_block_init(&out, KPRINT_DEBUG);
>	kprint_block(&out, "Stack trace:");
>
>	while(unwind_stack()) {
>		kprint_block(&out, "%p %s", address, symbol);
>	}
>	kprint_block_flush(&out);
> }

Assuming that kprint_block_flush() is a combination of
kprint_block_printit() and kprint_block_abort(), you
coulld make a macro wrapper for this to preclude leaks:

#define KPRINT_BLOCK(block, level, code) \
do { \
	struct kprint_block block; \
	kprint_block_init(&block, KPRINT_##level); \
	do { \
		code ; \
		kprint_block_printit(&block); \
	while (0); \
	kprint_block_abort(&block); \
} while(0)

The inner do { } while(0) region is so you can abort with "break".

(Or you can split it into KPRINT_BEGIN() and KPRINT_END() macros,
if that works out to be cleaner.)

  reply	other threads:[~2007-09-28  1:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-27 21:18 [RFC] New kernel-message logging API (take 2) Vegard Nossum
2007-09-28  1:38 ` linux [this message]
2007-09-28  7:31 ` Geert Uytterhoeven
2007-09-28  7:44   ` Kyle Moffett
2007-09-28 11:49     ` Vegard Nossum
2007-09-28 11:46   ` Vegard Nossum
2007-09-28  8:22 ` Dick Streefland
2007-09-28  9:45 ` Jan Engelhardt
2007-09-28 11:59   ` Vegard Nossum
2007-09-28 12:11 ` Vegard Nossum
2007-09-28 13:30   ` Miguel Ojeda
2007-09-28 13:55     ` Vegard Nossum
2007-09-28 14:00       ` Miguel Ojeda
2007-09-28 16:30   ` Rob Landley
2007-09-28 16:41     ` Vegard Nossum

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=20070928013822.28348.qmail@science.horizon.com \
    --to=linux@horizon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vegard.nossum@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox