Bug 117146 - Use ASSERT_DISABLED option for assertion purpose code in InlineBox
Summary: Use ASSERT_DISABLED option for assertion purpose code in InlineBox
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kangil Han
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-03 07:18 PDT by Kangil Han
Modified: 2013-06-04 03:26 PDT (History)
5 users (show)

See Also:


Attachments
Patch (1.25 KB, patch)
2013-06-03 07:21 PDT, Kangil Han
no flags Details | Formatted Diff | Diff
Patch (4.74 KB, patch)
2013-06-03 19:45 PDT, Kangil Han
no flags Details | Formatted Diff | Diff
Patch (3.73 KB, patch)
2013-06-03 23:55 PDT, Kangil Han
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kangil Han 2013-06-03 07:18:52 PDT
NDEBUG option is needed for any inInlineBoxDetach usage.
Comment 1 Kangil Han 2013-06-03 07:21:23 PDT
Created attachment 203586 [details]
Patch
Comment 2 Tim Horton 2013-06-03 07:48:08 PDT
Comment on attachment 203586 [details]
Patch

This is already building and has been a long time, and ASSERTs are compiled out in release builds, so why do we need this?
Comment 3 Kangil Han 2013-06-03 07:54:51 PDT
(In reply to comment #2)
> (From update of attachment 203586 [details])
> This is already building and has been a long time, and ASSERTs are compiled out in release builds, so why do we need this?

Yes, this patch doesn't change any behavior in release(even debug) build. But would bring us a code consistency(readability). :)
Comment 4 Alexey Proskuryakov 2013-06-03 11:00:27 PDT
Comment on attachment 203586 [details]
Patch

You are right that the code is not quite correct - NDEBUG and ASSERT_DISABLED usually go hand in hand, but sometimes people do use release builds with assertions enabled, and this code will fail to build in this configuration.

A better way to fix this is to change NDEBUG #ifs to ASSERT_DISABLED ones elsewhere in this file.
Comment 5 Kangil Han 2013-06-03 19:45:51 PDT
Created attachment 203647 [details]
Patch
Comment 6 Kangil Han 2013-06-03 19:46:51 PDT
(In reply to comment #4)
> (From update of attachment 203586 [details])
> You are right that the code is not quite correct - NDEBUG and ASSERT_DISABLED usually go hand in hand, but sometimes people do use release builds with assertions enabled, and this code will fail to build in this configuration.
> 
> A better way to fix this is to change NDEBUG #ifs to ASSERT_DISABLED ones elsewhere in this file.

Took ap's comment into consideration.
Comment 7 Alexey Proskuryakov 2013-06-03 23:16:56 PDT
Comment on attachment 203647 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=203647&action=review

> Source/WebCore/rendering/InlineBox.cpp:35
> -#ifndef NDEBUG
> +#if !ASSERT_DISABLED
>  #include <stdio.h>
>  #endif

stdio.h is needed for code below that is genuinely DEBUG-specific, so this change is not correct.

> Source/WebCore/rendering/InlineBox.cpp:95
> +#if !ASSERT_DISABLED
>      ASSERT(inInlineBoxDetach);
> -
> +#endif

This instance doesn't need to be guarded - ASSERT macro itself has the check.

> Source/WebCore/rendering/InlineBox.cpp:101
> -#ifndef NDEBUG
> +#if !ASSERT_DISABLED
>  const char* InlineBox::boxName() const

These functions are DEBUG specific, they are not related to assertions at all. So, NDEBUG was correct here.

> Source/WebCore/rendering/InlineBox.cpp:395
> -#ifndef NDEBUG
> +#if !ASSERT_DISABLED

Ditto.

> Source/WebCore/rendering/InlineBox.h:111
> -#ifndef NDEBUG
> +#if !ASSERT_DISABLED

Ditto.

> Source/WebCore/rendering/InlineBox.h:439
> -#ifndef NDEBUG
> +#if !ASSERT_DISABLED

Ditto.
Comment 8 Kangil Han 2013-06-03 23:55:53 PDT
Created attachment 203656 [details]
Patch
Comment 9 Kangil Han 2013-06-03 23:56:30 PDT
Thanks for the review and took ap's comment into consideration. :)
Comment 10 WebKit Commit Bot 2013-06-04 03:26:50 PDT
Comment on attachment 203656 [details]
Patch

Clearing flags on attachment: 203656

Committed r151164: <http://trac.webkit.org/changeset/151164>
Comment 11 WebKit Commit Bot 2013-06-04 03:26:53 PDT
All reviewed patches have been landed.  Closing bug.