Commits

Ondřej Surý committed 9cde91e

Debug output improvements in gdimageline/gdimageline_aa.c and jpeg/jpeg_read.c

Comments (0)

Files changed (2)

tests/gdimageline/gdimageline_aa.c

 	gdImageLine(im, 0, im->sy - 1, im->sx, im->sy - 1, 0x40FF0000);
 
 	if (!gdAssertImageEqualsToFile(filename, im)) {
-		printf("%s failed\n", filename);
+		gdTestErrorMsg("gdAssertImageEqualsToFile failed: <%s>\n", filename);
 		error = 1;
 	}
 	gdImageDestroy(im);
 	int error = 0;
 	char path[1024];
 
-	sprintf(path, "%s/gdimageline/gdimageline_aa_a_0_exp.png", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_a_0_exp.png", GDTEST_TOP_DIR);
 	error |= gen_image(path,0,1,10,100, 1);
 
-	sprintf(path, "%s/gdimageline/gdimageline_aa_a_1_exp.png", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_a_1_exp.png", GDTEST_TOP_DIR);
 	error |= gen_image(path,1,1,10,100, 2);
 
-	sprintf(path, "%s/gdimageline/gdimageline_aa_b_0_exp.png", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_b_0_exp.png", GDTEST_TOP_DIR);
 	error |= gen_image(path,2,-1,10,100, 1);
-	sprintf(path, "%s/gdimageline/gdimageline_aa_b_1_exp.png", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_b_1_exp.png", GDTEST_TOP_DIR);
 	error |= gen_image(path,1,-1,10,100, 2);
 
-	sprintf(path, "%s/gdimageline/gdimageline_aa_c_0_exp.png", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_c_0_exp.png", GDTEST_TOP_DIR);
 	error |= gen_image(path,0,1,100,10, 1);
-	sprintf(path, "%s/gdimageline/gdimageline_aa_c_1_exp.png", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_c_1_exp.png", GDTEST_TOP_DIR);
 	error |= gen_image(path,1,1,100,10, 2);
 
-	sprintf(path, "%s/gdimageline/gdimageline_aa_d_0_exp.png", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_d_0_exp.png", GDTEST_TOP_DIR);
 	error |= gen_image(path,2,-1,100,10, 1);
-	sprintf(path, "%s/gdimageline/gdimageline_aa_d_1_exp.png", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_d_1_exp.png", GDTEST_TOP_DIR);
 	error |= gen_image(path,1,-1,100,10, 2);
 
 	return error;

tests/jpeg/jpeg_read.c

 	FILE *fp;
 	char path[1024];
 
-	snprintf(path, sizeof(path), "%s/jpeg/conv_test.jpeg", GDTEST_TOP_DIR);
+	snprintf(path, sizeof(path)-1, "%s/jpeg/conv_test.jpeg", GDTEST_TOP_DIR);
 	fp = fopen(path, "rb");
 	if (!fp) {
 		gdTestErrorMsg("failed, cannot open file: %s\n", path);
 	}
 	snprintf(path, sizeof(path), "%s/jpeg/conv_test_exp.png", GDTEST_TOP_DIR);
 	if (!gdAssertImageEqualsToFile(path, im)) {
-		gdTestErrorMsg("gdAssertImageEqualsToFile failed.\n");
+		gdTestErrorMsg("gdAssertImageEqualsToFile failed: <%s>.\n", path);
 		gdImageDestroy(im);
 		return 1;
 	}