소스 검색

cleanup code to fix misc warnings

Mike Frysinger 19 년 전
부모
커밋
aa5545711b
1개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. 10 6
      test/misc/stdarg.c

+ 10 - 6
test/misc/stdarg.c

@@ -1,19 +1,23 @@
 /* copied from rsync */
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 #include <stdarg.h>
-void foo(const char *format, ...) {
+int foo(const char *format, ...)
+{
 	va_list ap;
-	int len;
+	size_t len;
 	char buf[5];
 
 	va_start(ap, format);
 	len = vsnprintf(0, 0, format, ap);
 	va_end(ap);
-	if (len != 5) exit(1);
+	if (len != 5) return(1);
 
-	if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
+	if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) return(1);
 
-	exit(0);
+	return(0);
 }
-int main() { foo("hello"); }
+int main(void) { return foo("hello"); }