From a3ed938e4a8000646c063fd717f04685837f0953 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 6 Jan 2019 18:27:58 +0300 Subject: [PATCH] gdiplus/tests: Add some missing return value checks (Coverity). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/gdiplus/tests/font.c | 3 ++- dlls/gdiplus/tests/graphics.c | 36 +++++++++++++++++++++++------------ dlls/gdiplus/tests/image.c | 2 +- dlls/gdiplus/tests/region.c | 9 ++++++--- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c index 0a3a3bef79a..03e7a04e081 100644 --- a/dlls/gdiplus/tests/font.c +++ b/dlls/gdiplus/tests/font.c @@ -159,7 +159,8 @@ static void test_createfont(void) expect(Ok, stat); GdipGetFontSize (font, &size); ok (size == 24, "Expected 24, got %f (with unit: %d)\n", size, i); - GdipGetFontUnit (font, &unit); + stat = GdipGetFontUnit (font, &unit); + ok (stat == Ok, "Failed to get font unit, %d.\n", stat); expect (i, unit); GdipDeleteFont(font); } diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index b0e3d8232bf..f2ff589ab5b 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -347,7 +347,8 @@ static void test_save_restore(void) log_state(state_a, &state_log); /* A state created by BeginContainer cannot be restored with RestoreGraphics. */ - GdipCreateFromHDC(hdc, &graphics1); + stat = GdipCreateFromHDC(hdc, &graphics1); + expect(Ok, stat); GdipSetInterpolationMode(graphics1, InterpolationModeBilinear); stat = GdipBeginContainer2(graphics1, &state_a); expect(Ok, stat); @@ -703,7 +704,8 @@ static void test_BeginContainer2(void) GdipGetTextContrast(graphics, &contrast); ok(defContrast == contrast, "Expected Text Contrast to be restored to %d, got %d\n", defContrast, contrast); - GdipGetTextRenderingHint(graphics, &texthint); + status = GdipGetTextRenderingHint(graphics, &texthint); + expect(Ok, status); ok(defTexthint == texthint, "Expected Text Hint to be restored to %d, got %d\n", defTexthint, texthint); /* test world transform */ @@ -722,7 +724,8 @@ static void test_BeginContainer2(void) status = GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform); expect(Ok, status); - GdipSetWorldTransform(graphics, transform); + status = GdipSetWorldTransform(graphics, transform); + expect(Ok, status); GdipDeleteMatrix(transform); transform = NULL; @@ -731,7 +734,8 @@ static void test_BeginContainer2(void) status = GdipCreateMatrix(&transform); expect(Ok, status); - GdipGetWorldTransform(graphics, transform); + status = GdipGetWorldTransform(graphics, transform); + expect(Ok, status); status = GdipGetMatrixElements(transform, elems); expect(Ok, status); ok(fabs(defTrans[0] - elems[0]) < 0.0001 && @@ -753,12 +757,14 @@ static void test_BeginContainer2(void) status = GdipBeginContainer2(graphics, &cont1); expect(Ok, status); - GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace); + status = GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace); + expect(Ok, status); status = GdipBeginContainer2(graphics, &cont2); expect(Ok, status); - GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace); + status = GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace); + expect(Ok, status); status = GdipEndContainer(graphics, cont2); expect(Ok, status); @@ -6572,12 +6578,18 @@ static void test_GdipFillRectanglesOnBitmapTextureBrush(void) GdipDeleteBrush((GpBrush*)brush); GdipDeleteGraphics(graphics); - GdipBitmapGetPixel(dst_img.bitmap, 0, 0, &color[0]); - GdipBitmapGetPixel(dst_img.bitmap, 0, 1, &color[1]); - GdipBitmapGetPixel(dst_img.bitmap, 1, 0, &color[2]); - GdipBitmapGetPixel(dst_img.bitmap, width/2, 0, &color[3]); - GdipBitmapGetPixel(dst_img.bitmap, width/2, height/2, &color[4]); - GdipBitmapGetPixel(dst_img.bitmap, 0, height/2, &color[5]); + status = GdipBitmapGetPixel(dst_img.bitmap, 0, 0, &color[0]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, 0, 1, &color[1]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, 1, 0, &color[2]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, width/2, 0, &color[3]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, width/2, height/2, &color[4]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, 0, height/2, &color[5]); + expect(Ok, status); ok(is_blue_color(color[0]) && is_blue_color(color[1]) && is_blue_color(color[2]) && color[3] == 0 && color[4] == 0 && color[5] == 0, diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index b31f32e1fa8..72a984a2eaf 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -2717,7 +2717,7 @@ static void test_multiframegif(void) expect(Ok, stat); color = 0xdeadbeef; - GdipBitmapGetPixel(bmp, 0, 0, &color); + stat = GdipBitmapGetPixel(bmp, 0, 0, &color); expect(Ok, stat); expect(0xff000000, color); diff --git a/dlls/gdiplus/tests/region.c b/dlls/gdiplus/tests/region.c index c2cbff01f69..d69f09db602 100644 --- a/dlls/gdiplus/tests/region.c +++ b/dlls/gdiplus/tests/region.c @@ -814,7 +814,8 @@ static void test_isinfinite(void) status = GdipCreateFromHDC(hdc, &graphics); expect(Ok, status); - GdipCreateRegion(®ion); + status = GdipCreateRegion(®ion); + expect(Ok, status); GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m); @@ -860,7 +861,8 @@ static void test_isempty(void) status = GdipCreateFromHDC(hdc, &graphics); expect(Ok, status); - GdipCreateRegion(®ion); + status = GdipCreateRegion(®ion); + expect(Ok, status); /* NULL arguments */ status = GdipIsEmptyRegion(NULL, NULL, NULL); @@ -1779,7 +1781,8 @@ static void test_getbounds(void) ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height); /* the world and page transforms are ignored */ - GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend); + status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend); + ok(status == Ok, "status %08x\n", status); GdipSetPageUnit(graphics, UnitInch); GdipSetPageScale(graphics, 2.0); status = GdipGetRegionBounds(region, graphics, &rectf);