[webkit-dev] Unused parameter warnings / errors / warning fixes
Alfonso Guerra
huperniketes at gmail.com
Mon Jan 26 12:38:43 PST 2015
On Mon, Jan 26, 2015 at 2:31 PM, Geoffrey Garen <ggaren at apple.com> wrote:
> And I do agree that it can be inconvenient to deal with these warnings in
> heavily #ifdef’d code. I think there are some good strategies for avoiding
> that, and I’d like to talk about specific irritating cases so I can propose
> the strategy I’d push for. Generally the strategy is to push more
> configuration specifics to the edges rather than spreading them through
> multiple functions.
>
>
> A few irritating cases for me:
>
> (1)
>
> static inline void validate(const Range& range)
> {
> UNUSED(range);
> IF_DEBUG(
> BeginTag* beginTag = LargeChunk::beginTag(range.begin());
> EndTag* endTag = LargeChunk::endTag(range.begin(), range.size());
>
> BASSERT(!beginTag->isEnd());
> BASSERT(range.size() >= largeMin);
> BASSERT(beginTag->size() == range.size());
>
> BASSERT(beginTag->size() == endTag->size());
> BASSERT(beginTag->isFree() == endTag->isFree());
> BASSERT(beginTag->hasPhysicalPages() == endTag->hasPhysicalPages());
> BASSERT(static_cast<BoundaryTag*>(endTag) ==
> static_cast<BoundaryTag*>(beginTag) || endTag->isEnd());
> );
> }
>
> (2)
>
> inline void vmValidate(size_t vmSize)
> {
> // We use getpagesize() here instead of vmPageSize because vmPageSize
> is
> // allowed to be larger than the OS's true page size.
>
> UNUSED(vmSize);
> BASSERT(vmSize);
> BASSERT(vmSize ==
> roundUpToMultipleOf(static_cast<size_t>(getpagesize()), vmSize));
> }
>
> (3)
>
> inline void vmValidate(void* p, size_t vmSize)
> {
> // We use getpagesize() here instead of vmPageSize because vmPageSize
> is
> // allowed to be larger than the OS's true page size.
>
> vmValidate(vmSize);
>
> UNUSED(p);
> BASSERT(p);
> BASSERT(p == mask(p, ~(getpagesize() - 1)));
> }
>
>
> The common theme in these cases is that I wanted to write a helper
> function to do some ASSERTs which compiled to nothing in a release build.
> Compiling the function to nothing made its parameters look like errors.
>
[snip]
>
> Geoff
>
Are there reasons any or all of these shouldn't be written as macros?
Alfonso
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20150126/4736d3be/attachment.html>
More information about the webkit-dev
mailing list