diff options
author | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 20:33:01 +0000 |
---|---|---|
committer | hans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 20:33:01 +0000 |
commit | 2315d03ac792d2465dc1e89bdc7a2e69fdf93395 (patch) | |
tree | 147d35eb91e95bef266e052e85bfcf226f12d3f6 /cc/font_atlas.cc | |
parent | 0a6bd7cd3f1091bc7b9568186b75615fbcb50202 (diff) | |
download | chromium_src-2315d03ac792d2465dc1e89bdc7a2e69fdf93395.zip chromium_src-2315d03ac792d2465dc1e89bdc7a2e69fdf93395.tar.gz chromium_src-2315d03ac792d2465dc1e89bdc7a2e69fdf93395.tar.bz2 |
Fix tautological compares in font_atlas.cc.
This fixes the following warnings from a recent version of Clang:
cc/font_atlas.cc:62:43: error: comparison of constant 128 with
expression of type 'char' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
cc/font_atlas.cc:45:39: error: comparison of constant 128 with
expression of type 'const char' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
The problem is that the char type is signed on this platform, and
therefore always < 128. The code really wants to work with the unsigned
values here.
BUG=163104
Review URL: https://chromiumcodereview.appspot.com/11416239
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170041 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/font_atlas.cc')
-rw-r--r-- | cc/font_atlas.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cc/font_atlas.cc b/cc/font_atlas.cc index aa464da..6fe22ae 100644 --- a/cc/font_atlas.cc +++ b/cc/font_atlas.cc @@ -42,7 +42,9 @@ void FontAtlas::drawOneLineOfTextInternal(SkCanvas* canvas, const SkPaint& paint gfx::Point position = destPosition; for (unsigned i = 0; i < textLine.length(); ++i) { // If the ASCII code is out of bounds, then index 0 is used, which is just a plain rectangle glyph. - int asciiIndex = (textLine[i] < 128) ? textLine[i] : 0; + unsigned asciiIndex = textLine[i]; + if (asciiIndex >= 128) + asciiIndex = 0; gfx::Rect glyphBounds = m_asciiToRectTable[asciiIndex]; SkIRect source = SkIRect::MakeXYWH(glyphBounds.x(), glyphBounds.y(), glyphBounds.width(), glyphBounds.height()); canvas->drawBitmapRect(m_atlas, &source, SkRect::MakeXYWH(position.x(), position.y(), glyphBounds.width(), glyphBounds.height()), &paint); @@ -59,7 +61,9 @@ gfx::Size FontAtlas::textSize(const std::string& text) for (size_t i = 0; i < lines.size(); ++i) { int lineWidth = 0; for (size_t j = 0; j < lines[i].size(); ++j) { - int asciiIndex = (lines[i][j] < 128) ? lines[i][j] : 0; + unsigned asciiIndex = lines[i][j]; + if (asciiIndex >= 128) + asciiIndex = 0; lineWidth += m_asciiToRectTable[asciiIndex].width(); } if (lineWidth > maxWidth) |