From: Richard Knutsson <ricknu-0@student.ltu.se>
To: "Moore, Robert" <robert.moore@intel.com>
Cc: Len Brown <lenb@kernel.org>,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH] utilities/: Compliment va_start() with va_end().
Date: Tue, 27 Nov 2007 03:10:50 +0100 [thread overview]
Message-ID: <474B7CAA.6030706@student.ltu.se> (raw)
In-Reply-To: <B28E9812BAF6E2498B7EC5C427F293A403BCBB45@orsmsx415.amr.corp.intel.com>
Moore, Robert wrote:
> Yes, it's official ANSI C, so I agree with the portability. I'm probably
> asking more about the history of the thing.
>
>
"the history of the thing"? Sorry, you lost me there. I know there were
a pre-ANSI
version of va_start() & co., but they seemed quite messy. When it comes
to va_end()
and maintainers, they often seem positive to this. I guess the
occasional lack off
va_end() is usually an oversight.
>
>> -----Original Message-----
>> From: Richard Knutsson [mailto:ricknu-0@student.ltu.se]
>> Sent: Monday, November 26, 2007 4:16 PM
>> To: Moore, Robert
>> Cc: Len Brown; linux-kernel@vger.kernel.org; linux-acpi@vger.kernel.org
>> Subject: Re: [PATCH] [ACPI] utilities/: Compliment va_start() with
>> va_end().
>>
>> Moore, Robert wrote:
>>
>>> This is an interesting one to me.
>>>
>>> From various documentation:
>>>
>>> After all arguments have been retrieved, va_end resets the pointer to
>>> NULL.
>>>
>>> va_end
>>> Each invocation of va_start must be matched by a corresponding
>>> invocation of va_end in the same function. After the call va_end(ap)
>>>
> the
>
>>> variable ap is undefined. Multiple transversals of the list, each
>>> bracketed by va_start and va_end are possible. va_end may be a macro
>>>
> or
>
>>> a function.
>>>
>>> Now, I'm all for defensive programming, but I don't really see the
>>>
> point
>
>>> of va_end when the list will be only traversed once.
>>>
>>>
>>>
>> First off, I think it is a good idea to follow the documentation, which
>> stated:
>> "va_end
>> Each invocation of va_start must be matched by a corresponding
>> invocation of va_end in the same function."
>>
>> Then if it is not really needed, does it take up extra cycles?
>> "In practice, with most C compilers, calling |va_end| does nothing
>> and you do not really need to call it. This is always true in the GNU
>>
> C
>
>> compiler."[1]
>>
>> Portability:
>> "But you might as well call |va_end| just in case your
>> program is someday compiled with a peculiar compiler."[2]
>> This argument is not as likely thou, but who knows? (Since I guess
>>
> Intel's
>
>> compiler is included in the 'most C compilers')
>>
>>
>>> We don't set all local pointers to NULL at function exit, what is the
>>> point of doing it here?
>>>
>>>
>> I think it is a good thing if the code follows the documentation, both
>> for the person who tries
>> to understand the code (to see when the 'args' is no longer needed and
>> not getting confused
>> by the absent of va_end(), after all, IMHO we should write the code how
>> we want things to
>> work and let the compiler do the optimizations (it usually does a
>>
> better
>
>> job at it then we do))
>> and to automated searches (that is how I found this one).
>>
>>> I suppose some implementation could allocate memory at va_start, but
>>>
> in
>
>>> practice, does this happen?
>>>
>>>
>> Not sure what you mean.
>>
>>> Bob
>>>
>>>
>>>
>> cu
>> Richard Knutsson
>>
>> [1]
>> http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.ht
>>
> ml
>
>> [2] The rest of [1]'s line.
>>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
WARNING: multiple messages have this Message-ID (diff)
From: Richard Knutsson <ricknu-0@student.ltu.se>
To: "Moore, Robert" <robert.moore@intel.com>
Cc: Len Brown <lenb@kernel.org>,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH] [ACPI] utilities/: Compliment va_start() with va_end().
Date: Tue, 27 Nov 2007 03:10:50 +0100 [thread overview]
Message-ID: <474B7CAA.6030706@student.ltu.se> (raw)
In-Reply-To: <B28E9812BAF6E2498B7EC5C427F293A403BCBB45@orsmsx415.amr.corp.intel.com>
Moore, Robert wrote:
> Yes, it's official ANSI C, so I agree with the portability. I'm probably
> asking more about the history of the thing.
>
>
"the history of the thing"? Sorry, you lost me there. I know there were
a pre-ANSI
version of va_start() & co., but they seemed quite messy. When it comes
to va_end()
and maintainers, they often seem positive to this. I guess the
occasional lack off
va_end() is usually an oversight.
>
>> -----Original Message-----
>> From: Richard Knutsson [mailto:ricknu-0@student.ltu.se]
>> Sent: Monday, November 26, 2007 4:16 PM
>> To: Moore, Robert
>> Cc: Len Brown; linux-kernel@vger.kernel.org; linux-acpi@vger.kernel.org
>> Subject: Re: [PATCH] [ACPI] utilities/: Compliment va_start() with
>> va_end().
>>
>> Moore, Robert wrote:
>>
>>> This is an interesting one to me.
>>>
>>> From various documentation:
>>>
>>> After all arguments have been retrieved, va_end resets the pointer to
>>> NULL.
>>>
>>> va_end
>>> Each invocation of va_start must be matched by a corresponding
>>> invocation of va_end in the same function. After the call va_end(ap)
>>>
> the
>
>>> variable ap is undefined. Multiple transversals of the list, each
>>> bracketed by va_start and va_end are possible. va_end may be a macro
>>>
> or
>
>>> a function.
>>>
>>> Now, I'm all for defensive programming, but I don't really see the
>>>
> point
>
>>> of va_end when the list will be only traversed once.
>>>
>>>
>>>
>> First off, I think it is a good idea to follow the documentation, which
>> stated:
>> "va_end
>> Each invocation of va_start must be matched by a corresponding
>> invocation of va_end in the same function."
>>
>> Then if it is not really needed, does it take up extra cycles?
>> "In practice, with most C compilers, calling |va_end| does nothing
>> and you do not really need to call it. This is always true in the GNU
>>
> C
>
>> compiler."[1]
>>
>> Portability:
>> "But you might as well call |va_end| just in case your
>> program is someday compiled with a peculiar compiler."[2]
>> This argument is not as likely thou, but who knows? (Since I guess
>>
> Intel's
>
>> compiler is included in the 'most C compilers')
>>
>>
>>> We don't set all local pointers to NULL at function exit, what is the
>>> point of doing it here?
>>>
>>>
>> I think it is a good thing if the code follows the documentation, both
>> for the person who tries
>> to understand the code (to see when the 'args' is no longer needed and
>> not getting confused
>> by the absent of va_end(), after all, IMHO we should write the code how
>> we want things to
>> work and let the compiler do the optimizations (it usually does a
>>
> better
>
>> job at it then we do))
>> and to automated searches (that is how I found this one).
>>
>>> I suppose some implementation could allocate memory at va_start, but
>>>
> in
>
>>> practice, does this happen?
>>>
>>>
>> Not sure what you mean.
>>
>>> Bob
>>>
>>>
>>>
>> cu
>> Richard Knutsson
>>
>> [1]
>> http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_28.ht
>>
> ml
>
>> [2] The rest of [1]'s line.
>>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
next prev parent reply other threads:[~2007-11-27 2:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200711250205.34299.lenb@kernel.org>
2007-11-26 22:14 ` [PATCH] utilities/: Compliment va_start() with va_end() Moore, Robert
2007-11-26 22:14 ` [PATCH] [ACPI] " Moore, Robert
2007-11-27 0:15 ` [PATCH] " Richard Knutsson
2007-11-27 0:15 ` [PATCH] [ACPI] " Richard Knutsson
2007-11-27 0:52 ` [PATCH] " Moore, Robert
2007-11-27 0:52 ` [PATCH] [ACPI] " Moore, Robert
2007-11-27 2:10 ` Richard Knutsson [this message]
2007-11-27 2:10 ` Richard Knutsson
2007-11-24 20:43 [PATCH] " Richard Knutsson
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=474B7CAA.6030706@student.ltu.se \
--to=ricknu-0@student.ltu.se \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robert.moore@intel.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 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.