diff options
author | John Stiles <johnstiles@google.com> | 2021-06-24 18:05:10 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2021-06-25 11:05:59 +0000 |
commit | e58831cd9578805634b986b434a20757277b3a36 (patch) | |
tree | c667982cc4c74753b4419fbd71ce019d3d974bba /docs | |
parent | 3a35f0b263cbdad011ffff6e5032f5996e946239 (diff) | |
download | skia-e58831cd9578805634b986b434a20757277b3a36.tar.gz |
Add format-specifier warnings to SkDebugf.
This CL fixes up many existing format-specifier violations in Skia.
Note that GCC has a warning for formatting nothing, so existing calls to
`SkDebugf("")` have been removed, or replaced with `SkDebugf("%s", "")`.
These were apparently meant to be used as a place to set a breakpoint.
Some of our clients also use SkDebug with bad format specifiers, so this
check is currently only enabled when SKIA_IMPLEMENTATION is true.
Change-Id: I8177a1298a624c6936adc24e0d8f481362a356d0
Bug: skia:12143
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/420902
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/examples/Bitmap_bytesPerPixel.cpp | 2 | ||||
-rw-r--r-- | docs/examples/Bitmap_computeByteSize.cpp | 2 | ||||
-rw-r--r-- | docs/examples/Bitmap_rowBytes.cpp | 3 | ||||
-rw-r--r-- | docs/examples/Bitmap_shiftPerPixel.cpp | 2 | ||||
-rw-r--r-- | docs/examples/Canvas_empty_constructor.cpp | 2 | ||||
-rw-r--r-- | docs/examples/IRect_height64.cpp | 2 | ||||
-rw-r--r-- | docs/examples/IRect_width64.cpp | 2 | ||||
-rw-r--r-- | docs/examples/ImageInfo_bytesPerPixel.cpp | 2 | ||||
-rw-r--r-- | docs/examples/ImageInfo_shiftPerPixel.cpp | 2 | ||||
-rw-r--r-- | docs/examples/ImageInfo_validRowBytes.cpp | 2 | ||||
-rw-r--r-- | docs/examples/Paint_move_operator.cpp | 2 | ||||
-rw-r--r-- | docs/examples/Path_readFromMemory.cpp | 4 | ||||
-rw-r--r-- | docs/examples/Pixmap_addr.cpp | 4 | ||||
-rw-r--r-- | docs/examples/Pixmap_computeByteSize.cpp | 2 | ||||
-rw-r--r-- | docs/examples/Pixmap_rowBytes.cpp | 2 | ||||
-rw-r--r-- | docs/examples/Pixmap_shiftPerPixel.cpp | 2 | ||||
-rw-r--r-- | docs/examples/Rect_equal_operator.cpp | 8 |
17 files changed, 23 insertions, 22 deletions
diff --git a/docs/examples/Bitmap_bytesPerPixel.cpp b/docs/examples/Bitmap_bytesPerPixel.cpp index a0e92a14d3..db9d33f2d9 100644 --- a/docs/examples/Bitmap_bytesPerPixel.cpp +++ b/docs/examples/Bitmap_bytesPerPixel.cpp @@ -17,7 +17,7 @@ void draw(SkCanvas* canvas) { } ) { bitmap.setInfo(info.makeColorType(colorType)); SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d\n", - colors[colorType], 13 - strlen(colors[colorType]), " ", + colors[colorType], (int)(13 - strlen(colors[colorType])), " ", bitmap.bytesPerPixel()); } } diff --git a/docs/examples/Bitmap_computeByteSize.cpp b/docs/examples/Bitmap_computeByteSize.cpp index a43ffddb34..891396e144 100644 --- a/docs/examples/Bitmap_computeByteSize.cpp +++ b/docs/examples/Bitmap_computeByteSize.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { for (int height: { 1, 1000, 1000000 } ) { SkImageInfo imageInfo = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType); bitmap.setInfo(imageInfo, width * 5); - SkDebugf("width: %7d height: %7d computeByteSize: %13lld\n", width, height, + SkDebugf("width: %7d height: %7d computeByteSize: %13zu\n", width, height, bitmap.computeByteSize()); } } diff --git a/docs/examples/Bitmap_rowBytes.cpp b/docs/examples/Bitmap_rowBytes.cpp index ee6468a0bf..47041af884 100644 --- a/docs/examples/Bitmap_rowBytes.cpp +++ b/docs/examples/Bitmap_rowBytes.cpp @@ -7,7 +7,8 @@ void draw(SkCanvas* canvas) { SkBitmap bitmap; for (int rowBytes : { 2, 8 } ) { bool result = bitmap.setInfo(SkImageInfo::MakeA8(4, 4), rowBytes); - SkDebugf("setInfo returned:%s rowBytes:%d\n", result ? "true " : "false", bitmap.rowBytes()); + SkDebugf("setInfo returned:%s rowBytes:%zu\n", + result ? "true " : "false", bitmap.rowBytes()); } } } // END FIDDLE diff --git a/docs/examples/Bitmap_shiftPerPixel.cpp b/docs/examples/Bitmap_shiftPerPixel.cpp index 72322112a2..a011f7eee5 100644 --- a/docs/examples/Bitmap_shiftPerPixel.cpp +++ b/docs/examples/Bitmap_shiftPerPixel.cpp @@ -17,7 +17,7 @@ void draw(SkCanvas* canvas) { } ) { bitmap.setInfo(info.makeColorType(colorType)); SkDebugf("color: k" "%s" "_SkColorType" "%*s" "shiftPerPixel: %d\n", - colors[colorType], 14 - strlen(colors[colorType]), " ", + colors[colorType], (int)(14 - strlen(colors[colorType])), " ", bitmap.shiftPerPixel()); } } diff --git a/docs/examples/Canvas_empty_constructor.cpp b/docs/examples/Canvas_empty_constructor.cpp index 3bc90ab6ef..72f2ca21ed 100644 --- a/docs/examples/Canvas_empty_constructor.cpp +++ b/docs/examples/Canvas_empty_constructor.cpp @@ -5,7 +5,7 @@ REG_FIDDLE(Canvas_empty_constructor, 256, 256, true, 0) { static void check_for_rotated_ctm(const SkCanvas* canvas) { const SkM44 matrix = canvas->getLocalToDevice(); - SkDebugf("ctm is identity = \n", matrix == SkM44() ? "true" : "false"); + SkDebugf("ctm is identity = %s\n", matrix == SkM44() ? "true" : "false"); } void draw(SkCanvas* canvas) { diff --git a/docs/examples/IRect_height64.cpp b/docs/examples/IRect_height64.cpp index 3fafc07244..91aab2ebeb 100644 --- a/docs/examples/IRect_height64.cpp +++ b/docs/examples/IRect_height64.cpp @@ -5,6 +5,6 @@ REG_FIDDLE(IRect_height64, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkIRect large = { 1, -2147483647, 2, 2147483644 }; - SkDebugf("height: %d height64: %lld\n", large.height(), large.height64()); + SkDebugf("height: %d height64: %" PRId64 "\n", large.height(), large.height64()); } } // END FIDDLE diff --git a/docs/examples/IRect_width64.cpp b/docs/examples/IRect_width64.cpp index 9aa25d860a..25903b293e 100644 --- a/docs/examples/IRect_width64.cpp +++ b/docs/examples/IRect_width64.cpp @@ -5,6 +5,6 @@ REG_FIDDLE(IRect_width64, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkIRect large = { -2147483647, 1, 2147483644, 2 }; - SkDebugf("width: %d width64: %lld\n", large.width(), large.width64()); + SkDebugf("width: %d width64: %" PRId64 "\n", large.width(), large.width64()); } } // END FIDDLE diff --git a/docs/examples/ImageInfo_bytesPerPixel.cpp b/docs/examples/ImageInfo_bytesPerPixel.cpp index 29f2046160..b15034f67f 100644 --- a/docs/examples/ImageInfo_bytesPerPixel.cpp +++ b/docs/examples/ImageInfo_bytesPerPixel.cpp @@ -15,7 +15,7 @@ void draw(SkCanvas* canvas) { } ) { SkImageInfo info = SkImageInfo::Make(1, 1, colorType, kOpaque_SkAlphaType); SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d\n", - colors[colorType], 13 - strlen(colors[colorType]), " ", + colors[colorType], (int)(13 - strlen(colors[colorType])), " ", info.bytesPerPixel()); } } diff --git a/docs/examples/ImageInfo_shiftPerPixel.cpp b/docs/examples/ImageInfo_shiftPerPixel.cpp index f83e5f7792..e16a8964bb 100644 --- a/docs/examples/ImageInfo_shiftPerPixel.cpp +++ b/docs/examples/ImageInfo_shiftPerPixel.cpp @@ -30,7 +30,7 @@ void draw(SkCanvas* canvas) { } ) { SkImageInfo info = SkImageInfo::Make(1, 1, colorType, kOpaque_SkAlphaType); SkDebugf("color: k" "%s" "_SkColorType" "%*s" "shiftPerPixel: %d\n", - color_type(colorType), 14 - strlen(color_type(colorType)), " ", + color_type(colorType), (int)(14 - strlen(color_type(colorType))), " ", info.shiftPerPixel()); } } diff --git a/docs/examples/ImageInfo_validRowBytes.cpp b/docs/examples/ImageInfo_validRowBytes.cpp index d0f7cb848b..80fa00a473 100644 --- a/docs/examples/ImageInfo_validRowBytes.cpp +++ b/docs/examples/ImageInfo_validRowBytes.cpp @@ -6,7 +6,7 @@ REG_FIDDLE(ImageInfo_validRowBytes, 256, 256, true, 0) { void draw(SkCanvas* canvas) { SkImageInfo info = SkImageInfo::MakeN32Premul(16, 8); for (size_t rowBytes = 60; rowBytes < 72; rowBytes += sizeof(SkPMColor)) { - SkDebugf("validRowBytes(%llu): %s\n", rowBytes, info.validRowBytes(rowBytes) ? + SkDebugf("validRowBytes(%zu): %s\n", rowBytes, info.validRowBytes(rowBytes) ? "true" : "false"); } } diff --git a/docs/examples/Paint_move_operator.cpp b/docs/examples/Paint_move_operator.cpp index a9d86057e1..6b6f92b5ec 100644 --- a/docs/examples/Paint_move_operator.cpp +++ b/docs/examples/Paint_move_operator.cpp @@ -7,6 +7,6 @@ void draw(SkCanvas* canvas) { SkPaint paint1, paint2; paint1.setColor(SK_ColorRED); paint2 = std::move(paint1); - SkDebugf("SK_ColorRED == paint2.getColor()\n", SK_ColorRED == paint2.getColor() ? '=' : '!'); + SkDebugf("SK_ColorRED %c= paint2.getColor()\n", SK_ColorRED == paint2.getColor() ? '=' : '!'); } } // END FIDDLE diff --git a/docs/examples/Path_readFromMemory.cpp b/docs/examples/Path_readFromMemory.cpp index f576a48b6a..c9c41a7e18 100644 --- a/docs/examples/Path_readFromMemory.cpp +++ b/docs/examples/Path_readFromMemory.cpp @@ -12,9 +12,9 @@ void draw(SkCanvas* canvas) { path.writeToMemory(storage.begin()); size_t wrongSize = size - 4; size_t bytesRead = copy.readFromMemory(storage.begin(), wrongSize); - SkDebugf("length = %u; returned by readFromMemory = %u\n", wrongSize, bytesRead); + SkDebugf("length = %zu; returned by readFromMemory = %zu\n", wrongSize, bytesRead); size_t largerSize = size + 4; bytesRead = copy.readFromMemory(storage.begin(), largerSize); - SkDebugf("length = %u; returned by readFromMemory = %u\n", largerSize, bytesRead); + SkDebugf("length = %zu; returned by readFromMemory = %zu\n", largerSize, bytesRead); } } // END FIDDLE diff --git a/docs/examples/Pixmap_addr.cpp b/docs/examples/Pixmap_addr.cpp index 8e2fd2a8b3..eabe576405 100644 --- a/docs/examples/Pixmap_addr.cpp +++ b/docs/examples/Pixmap_addr.cpp @@ -9,10 +9,10 @@ void draw(SkCanvas* canvas) { SkPixmap pixmap(SkImageInfo::Make(image->width(), image->height(), kN32_SkColorType, image->alphaType()), (const void*) &pixels.front(), image->width() * 4); image->readPixels(nullptr, pixmap, 0, 0); - SkDebugf("pixels address: 0x%llx\n", pixmap.addr()); + SkDebugf("pixels address: 0x%p\n", pixmap.addr()); SkPixmap inset; if (pixmap.extractSubset(&inset, {128, 128, 512, 512})) { - SkDebugf("inset address: 0x%llx\n", inset.addr()); + SkDebugf("inset address: 0x%p\n", inset.addr()); } } } // END FIDDLE diff --git a/docs/examples/Pixmap_computeByteSize.cpp b/docs/examples/Pixmap_computeByteSize.cpp index eb0e5f99c5..b45d8feb08 100644 --- a/docs/examples/Pixmap_computeByteSize.cpp +++ b/docs/examples/Pixmap_computeByteSize.cpp @@ -9,7 +9,7 @@ void draw(SkCanvas* canvas) { for (int height: { 1, 1000, 1000000 } ) { SkImageInfo imageInfo = SkImageInfo::MakeN32(width, height, kPremul_SkAlphaType); pixmap.reset(imageInfo, nullptr, width * 5); - SkDebugf("width: %7d height: %7d computeByteSize: %13lld\n", width, height, + SkDebugf("width: %7d height: %7d computeByteSize: %13zu\n", width, height, pixmap.computeByteSize()); } } diff --git a/docs/examples/Pixmap_rowBytes.cpp b/docs/examples/Pixmap_rowBytes.cpp index 4cffbece8c..71a0abe157 100644 --- a/docs/examples/Pixmap_rowBytes.cpp +++ b/docs/examples/Pixmap_rowBytes.cpp @@ -7,7 +7,7 @@ void draw(SkCanvas* canvas) { SkPixmap badPixmap = {SkImageInfo::MakeA8(4, 4), nullptr, 2}; SkPixmap okPixmap = {SkImageInfo::MakeA8(4, 4), nullptr, 8}; for (auto& pixmap : { badPixmap, okPixmap } ) { - SkDebugf("rowBytes: %d minRowBytes: %d\n", pixmap.rowBytes(), + SkDebugf("rowBytes: %zu minRowBytes: %zu\n", pixmap.rowBytes(), pixmap.info().minRowBytes()); } } diff --git a/docs/examples/Pixmap_shiftPerPixel.cpp b/docs/examples/Pixmap_shiftPerPixel.cpp index cd48ad9929..f169df5f4e 100644 --- a/docs/examples/Pixmap_shiftPerPixel.cpp +++ b/docs/examples/Pixmap_shiftPerPixel.cpp @@ -29,7 +29,7 @@ void draw(SkCanvas* canvas) { kGray_8_SkColorType, kRGBA_F16_SkColorType } ) { SkPixmap pixmap(info.makeColorType(colorType), nullptr, 4); SkDebugf("color: k" "%s" "_SkColorType" "%*s" "bytesPerPixel: %d shiftPerPixel: %d\n", - color_type(colorType), 10 - strlen(color_type(colorType)), " ", + color_type(colorType), (int)(10 - strlen(color_type(colorType))), " ", pixmap.info().bytesPerPixel(), pixmap.shiftPerPixel()); } } diff --git a/docs/examples/Rect_equal_operator.cpp b/docs/examples/Rect_equal_operator.cpp index d44dddcd1e..4f816bbd0c 100644 --- a/docs/examples/Rect_equal_operator.cpp +++ b/docs/examples/Rect_equal_operator.cpp @@ -8,11 +8,11 @@ void draw(SkCanvas* canvas) { SkRect negZero = {-0.0f, -0.0f, 2, 2}; SkDebugf("{%g, %g, %g, %g} %c= {%g, %g, %g, %g} %s numerically equal\n", test.fLeft, test.fTop, test.fRight, test.fBottom, - negZero.fLeft, negZero.fTop, negZero.fRight, negZero.fBottom, test == negZero ? '=' : '!', - test.fLeft == negZero.fLeft && test.fTop == negZero.fTop && - test.fRight == negZero.fRight && test.fBottom == negZero.fBottom ? - "and are" : "yet are not"); + negZero.fLeft, negZero.fTop, negZero.fRight, negZero.fBottom, + (test.fLeft == negZero.fLeft && test.fTop == negZero.fTop && + test.fRight == negZero.fRight && test.fBottom == negZero.fBottom) ? + "and are" : "yet are not"); }; SkRect tests[] = {{0, 0, 2, 2}, {-0, -0, 2, 2}, {0.0f, 0.0f, 2, 2}}; SkDebugf("tests are %s" "equal\n", tests[0] == tests[1] && tests[1] == tests[2] ? "" : "not "); |