Changeset 88256 in webkit


Ignore:
Timestamp:
Jun 7, 2011 12:55:04 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-07 Dmitry Lomov <dslomov@google.com>

Reviewed by David Levin.

https://bugs.webkit.org/show_bug.cgi?id=62215
Allow comparisons with 0 in LIKELY and UNLIKELY macros.

  • Scripts/webkitpy/style/checkers/cpp.py:
  • Scripts/webkitpy/style/checkers/cpp_unittest.py:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r88246 r88256  
     12011-06-07  Dmitry Lomov  <dslomov@google.com>
     2
     3        Reviewed by David Levin.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=62215
     6        Allow comparisons with 0 in LIKELY and UNLIKELY macros.
     7
     8        * Scripts/webkitpy/style/checkers/cpp.py:
     9        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
     10
    1112011-06-07  Nico Weber  <thakis@chromium.org>
    212
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py

    r88179 r88256  
    23422342    # Include NULL here so that users don't have to convert NULL to 0 first and then get this error.
    23432343    if search(r'[=!]=\s*(NULL|0|true|false)\W', line) or search(r'\W(NULL|0|true|false)\s*[=!]=', line):
    2344         error(line_number, 'readability/comparison_to_zero', 5,
    2345               'Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.')
     2344        if not search('LIKELY', line) and not search('UNLIKELY', line):
     2345            error(line_number, 'readability/comparison_to_zero', 5,
     2346                  'Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.')
    23462347
    23472348
  • trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

    r88179 r88256  
    41384138            'if (othertrue == fontType)',
    41394139            '')
     4140        self.assert_lint(
     4141            'if (LIKELY(foo == 0))',
     4142            '')
     4143        self.assert_lint(
     4144            'if (UNLIKELY(foo == 0))',
     4145            '')
     4146        self.assert_lint(
     4147            'if (LIKELY(foo == NULL))',
     4148            'Use 0 instead of NULL.  [readability/null] [5]')
     4149        self.assert_lint(
     4150            'if (UNLIKELY(foo == NULL))',
     4151            'Use 0 instead of NULL.  [readability/null] [5]')
     4152
    41404153
    41414154    def test_using_std(self):
Note: See TracChangeset for help on using the changeset viewer.