fix various gcc/clang warnings found with -Wall

master
Mike Frysinger 2016-05-13 22:19:26 -04:00
parent 8bdfede0a4
commit 75c38f6b32
9 changed files with 21 additions and 20 deletions

View File

@ -3508,9 +3508,11 @@ static void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int co
return;
} else {
double ag;
ag = (abs(dy) < abs(dx)) ? cos(atan2(dy, dx)) : sin(atan2(dy, dx));
/* Cast the long to an int to avoid compiler warnings about truncation.
* This isn't a problem as computed dy/dx values came from ints above. */
ag = fabs(abs((int)dy) < abs((int)dx) ? cos(atan2(dy, dx)) : sin(atan2(dy, dx)));
if (ag != 0) {
wid = abs(thick / ag);
wid = thick / ag;
} else {
wid = 1;
}
@ -3528,7 +3530,7 @@ static void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int co
return;
}
if (abs(dx) > abs(dy)) {
if (abs((int)dx) > abs((int)dy)) {
if (dx < 0) {
tmp = x1;
x1 = x2;

View File

@ -2415,8 +2415,8 @@ BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst,
gdImageGetClip(dst, &c1x, &c1y, &c2x, &c2y);
end_x = bbox.width + (int) fabs(bbox.x);
end_y = bbox.height + (int) fabs(bbox.y);
end_x = bbox.width + abs(bbox.x);
end_y = bbox.height + abs(bbox.y);
/* Get inverse affine to let us work with destination -> source */
gdAffineInvert(inv, affine);
@ -2518,7 +2518,7 @@ BGD_DECLARE(int) gdTransformAffineBoundingBox(gdRectPtr src, const double affine
BGD_DECLARE(int) gdImageSetInterpolationMethod(gdImagePtr im, gdInterpolationMethod id)
{
if (im == NULL || id < 0 || (uintmax_t)id > GD_METHOD_COUNT) {
if (im == NULL || (uintmax_t)id > GD_METHOD_COUNT) {
return 0;
}

View File

@ -44,7 +44,7 @@ main (int argc, char *argv[])
#ifdef JISX0208
char *s = "Hello. こんにちは Qyjpqg,"; /* String to draw. */
#else
char *s = "Hello. äöü Qyjpqg,"; /* String to draw. */
char *s = "Hello. こんにちは Qyjpqg,"; /* String to draw. */
#endif
double sz = 40.;

View File

@ -51,11 +51,13 @@ static void run_tests(gdImagePtr im, int *error)
} \
} while (0)
#define CHECK_PIXEL(x, y, expected) do { \
#define CHECK_PIXEL(x, y, expected) \
do { \
int pix; \
gdImageSetClip(im, 0, 0, 4, 4); \
c = gdImageGetPixel(im, (x), (y)); \
if (gdTestAssert(c == (expected)) != 1) { \
printf("%d is expected, but %d\n", expected, c); \
pix = gdImageGetPixel(im, (x), (y)); \
if (gdTestAssert(pix == (expected)) != 1) { \
printf("%d is expected, but %d\n", expected, pix); \
*error = -1; \
} \
} while (0)

View File

@ -6,8 +6,8 @@
int main()
{
gdImagePtr im, tile;
int im_white, tile_red, tile_blue;
int x, y, error = 0;
int tile_red, tile_blue;
int error = 0;
char path[1024];
im = gdImageCreate(200, 150);

View File

@ -23,7 +23,7 @@ save(gdImagePtr im, const char *filename) {
gdImagePng(im, out);
fclose(out);
#else
im, filename;
(void)im, (void)filename;
#endif
}/* save*/
@ -87,8 +87,7 @@ void blurblank(gdImagePtr im, int radius, double sigma) {
void do_test()
{
gdImagePtr im, imref, tmp;
gdImagePtr same, same2;
gdImagePtr im, imref;
im = mkwhite(WIDTH, HEIGHT);
imref = mkwhite(WIDTH, HEIGHT);

View File

@ -11,7 +11,6 @@ int main()
const char *file_im = "gdimagerotate/php_bug_64898.png";
const char *file_exp = "gdimagerotate/php_bug_64898_exp.png";
FILE *fp;
int color;
sprintf(path, "%s/%s", GDTEST_TOP_DIR, file_im);

View File

@ -58,8 +58,7 @@ void scaletest(int x, int y, int nx, int ny)
void do_test(int x, int y, int nx, int ny)
{
gdImagePtr im, imref, tmp;
gdImagePtr same, same2;
gdImagePtr im, imref, same;
im = mkwhite(x, y);
imref = mkwhite(x, y);

View File

@ -77,7 +77,7 @@ void gdTestImageDiff(gdImagePtr buf_a, gdImagePtr buf_b,
r1 = gdTrueColorGetRed(c1);
r2 = gdTrueColorGetRed(c2);
diff_r = abs (r1 - r2);
/* diff_r *= 4; /* emphasize */
// diff_r *= 4; /* emphasize */
if (diff_r) {
diff_r += gdRedMax/2; /* make sure it's visible */
}