From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Ingo Molnar <mingo@elte.hu>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] markers: remove 2 exported symbols
Date: Fri, 10 Oct 2008 16:02:04 +0800 [thread overview]
Message-ID: <48EF0BFC.2090004@cn.fujitsu.com> (raw)
In-Reply-To: <20081009142758.GE15553@Krystal>
Mathieu Desnoyers wrote:
>
> See my comment in marker.h :
>
> * @args: variable argument list pointer. Use a pointer to overcome C's
> * inability to pass this around as a pointer in a portable manner in
> * the callee otherwise.
>
> It's an information hard to find on the web (cannot find my original
> source anymore, it's mainly through forums saying that the
> http://c-faq.com/varargs/handoff.html _doesn't_ work), but you'll
> understand that promotion of array to pointer when passed to a function
> poses problem when you try to pass this array to another function. The
> following won't work on architectures where va_list is defined as an
> array :
>
> void C(const char *fmt, va_list argp)
> {
> ....
> }
>
> void B(const char *fmt, va_list argp)
> {
> C(fmt, argp); <--- this won't work, because we try to pass a pointer
> to a function expecting an array.
> }
>
> void A(const char *fmt, ...)
> {
> va_list argp;
>
> argp = va_start(fmt);
> B(fmt, argp);
> va_end(argp);
> }
>
> The way to permit it is to pass a pointer to argp instead :
>
> void C(const char *fmt, va_list *argp)
> {
> ....
> }
>
> void B(const char *fmt, va_list *argp)
> {
> C(fmt, argp);
> }
>
> void A(const char *fmt, ...)
> {
> va_list argp;
>
> argp = va_start(fmt);
> B(fmt, &argp);
> va_end(argp);
> }
>
> Mathieu
>
Hi Mathieu,
I understood, and the comp.lang.c FAQ seems very authoritative.
but in the kernel source I found these:
asmlinkage int vprintk(const char *fmt, va_list args)
{
......
printed_len += vscnprintf(printk_buf + printed_len,
sizeof(printk_buf) - printed_len, fmt, args);
.....
}
int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
{
int i;
i=vsnprintf(buf,size,fmt,args);
return (i >= size) ? (size - 1) : i;
}
int vsnprintf(char *buf, size_t size, const char *fmt, va_list args);
Thanks, Lai
prev parent reply other threads:[~2008-10-10 8:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-08 2:23 [PATCH] markers: remove 2 exported symbols Lai Jiangshan
2008-10-08 2:43 ` Mathieu Desnoyers
2008-10-08 3:05 ` Lai Jiangshan
2008-10-08 3:53 ` Mathieu Desnoyers
2008-10-09 2:19 ` Lai Jiangshan
2008-10-09 14:27 ` Mathieu Desnoyers
2008-10-10 8:02 ` Lai Jiangshan [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=48EF0BFC.2090004@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@polymtl.ca \
--cc=mingo@elte.hu \
/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