bin/128561: [patch] compile warning fixes for bsdtar test harness

Jaakko Heinonen jh at saunalahti.fi
Mon Nov 3 10:00:14 PST 2008


>Number:         128561
>Category:       bin
>Synopsis:       [patch] compile warning fixes for bsdtar test harness
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 03 18:00:11 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Jaakko Heinonen
>Release:        FreeBSD 8.0-CURRENT amd64
>Organization:
>Environment:
	
>Description:
Compiling bsdtar test suite on amd64 gives some warnings:

main.c: In function 'test_assert_equal_string':
main.c:327: warning: format '%d' expects type 'int', but argument 3 has type 'size_t'
main.c:330: warning: format '%d' expects type 'int', but argument 3 has type 'size_t'
main.c: In function 'hexdump':
main.c:405: warning: format '%04x' expects type 'unsigned int', but argument 3 has type 'size_t'
main.c: In function 'test_assert_empty_file':
main.c:497: warning: comparison between signed and unsigned
main.c:497: warning: signed and unsigned type in conditional expression


>How-To-Repeat:
	
>Fix:

	

--- bsdtar-test-compile-warnings.diff begins here ---
Index: test/main.c
===================================================================
--- test/main.c	(revision 183511)
+++ test/main.c	(working copy)
@@ -324,10 +324,10 @@ test_assert_equal_string(const char *fil
 	    file, line);
 	fprintf(stderr, "      %s = ", e1);
 	strdump(v1);
-	fprintf(stderr, " (length %d)\n", v1 == NULL ? 0 : strlen(v1));
+	fprintf(stderr, " (length %zd)\n", v1 == NULL ? 0 : strlen(v1));
 	fprintf(stderr, "      %s = ", e2);
 	strdump(v2);
-	fprintf(stderr, " (length %d)\n", v2 == NULL ? 0 : strlen(v2));
+	fprintf(stderr, " (length %zd)\n", v2 == NULL ? 0 : strlen(v2));
 	report_failure(extra);
 	return (0);
 }
@@ -402,7 +402,7 @@ hexdump(const char *p, const char *ref, 
 	char sep;
 
 	for(i=0; i < l; i+=16) {
-		fprintf(stderr, "%04x", i + offset);
+		fprintf(stderr, "%04zx", i + offset);
 		sep = ' ';
 		for (j = 0; j < 16 && i + j < l; j++) {
 			if (ref != NULL && p[i + j] != ref[i + j])
@@ -494,7 +494,8 @@ test_assert_empty_file(const char *f1fmt
 	if (fd < 0) {
 		fprintf(stderr, "    Unable to open %s\n", f1);
 	} else {
-		s = sizeof(buff) < st.st_size ? sizeof(buff) : st.st_size;
+		s = (sizeof(buff) < (size_t)st.st_size) ?
+		    (ssize_t)sizeof(buff) : st.st_size;
 		s = read(fd, buff, s);
 		hexdump(buff, NULL, s, 0);
 	}
--- bsdtar-test-compile-warnings.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list