This patch fixes most of current reasons to generate compiler warnings.
The changes consist of:
 - adding missing casts
 - hiding or unhiding function declarations
 - including headers where missing
 - add __UNCONST when assigning a const char * to a char *
 - adding missing return statements
 - changing some types from unsigned to signed, as the code seems to want
   signed ints
 - converting old-style function definitions to current style (i.e.,
   void func(param1, param2) short param1, param2; {...} to
   void func (short param1, short param2) {...})
 - making the compiler silent about signed vs unsigned comparisons. We
   have too many of those in the new libc to fix.
A number of bugs in the test set were fixed. These bugs were never
triggered with our old libc. Consequently, these tests are now forced to
link with the new libc or they will generate errors (in particular tests 43
and 55).
Most changes in NetBSD libc are limited to moving aroudn "#ifndef __minix"
or stuff related to Minix-specific things (code in sys-minix or gen/minix).
		
	
			
		
			
				
	
	
		
			90 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			90 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
#include <errno.h>
 | 
						|
#include <stdint.h>
 | 
						|
#include <stdio.h>
 | 
						|
#include <stdlib.h>
 | 
						|
#include <unistd.h>
 | 
						|
 | 
						|
#if defined(__clang__)
 | 
						|
#pragma clang diagnostic ignored "-Wtautological-compare"
 | 
						|
#endif
 | 
						|
 | 
						|
#define MAX_ERROR 4
 | 
						|
static int errct;
 | 
						|
 | 
						|
/* test strtol */
 | 
						|
#define	TYPE        long
 | 
						|
#define	TYPEU       unsigned long
 | 
						|
#define	TYPE_FUNC	strtol
 | 
						|
#include "test45.h"
 | 
						|
#undef	TYPE
 | 
						|
#undef	TYPEU
 | 
						|
#undef	TYPE_FUNC
 | 
						|
 | 
						|
/* test strtoul */
 | 
						|
#define	TYPE        unsigned long
 | 
						|
#define	TYPEU       unsigned long
 | 
						|
#define	TYPE_FUNC	strtoul
 | 
						|
#include "test45.h"
 | 
						|
#undef	TYPE
 | 
						|
#undef	TYPEU
 | 
						|
#undef	TYPE_FUNC
 | 
						|
 | 
						|
#ifdef __LONG_LONG_SUPPORTED
 | 
						|
 | 
						|
/* test strtoll */
 | 
						|
#define	TYPE        long long
 | 
						|
#define	TYPEU       unsigned long long
 | 
						|
#define	TYPE_FUNC	strtoll
 | 
						|
#include "test45.h"
 | 
						|
#undef	TYPE
 | 
						|
#undef	TYPEU
 | 
						|
#undef	TYPE_FUNC
 | 
						|
 | 
						|
/* test strtoull */
 | 
						|
#define	TYPE        long long
 | 
						|
#define	TYPEU       unsigned long long
 | 
						|
#define	TYPE_FUNC	strtoull
 | 
						|
#include "test45.h"
 | 
						|
#undef	TYPE
 | 
						|
#undef	TYPEU
 | 
						|
#undef	TYPE_FUNC
 | 
						|
 | 
						|
#endif /* defined(__LONG_LONG_SUPPORTED) */
 | 
						|
 | 
						|
static void quit(void)
 | 
						|
{
 | 
						|
	if (errct == 0) 
 | 
						|
	{
 | 
						|
		printf("ok\n");
 | 
						|
		exit(0);
 | 
						|
	} 
 | 
						|
	else 
 | 
						|
	{
 | 
						|
		printf("%d errors\n", errct);
 | 
						|
		exit(1);
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
int main(int argc, char **argv)
 | 
						|
{
 | 
						|
#ifdef __LONG_LONG_SUPPORTED
 | 
						|
	printf("Test 45 (GCC) ");
 | 
						|
#else
 | 
						|
	printf("Test 45 (ACK) ");
 | 
						|
#endif
 | 
						|
	fflush(stdout);
 | 
						|
 | 
						|
	/* run long/unsigned long tests */
 | 
						|
	test_strtol();
 | 
						|
	test_strtoul();
 | 
						|
 | 
						|
	/* run long long/unsigned long long tests (GCC only) */
 | 
						|
#ifdef __LONG_LONG_SUPPORTED
 | 
						|
	test_strtoll();
 | 
						|
	test_strtoull();
 | 
						|
#endif /* defined(__LONG_LONG_SUPPORTED) */
 | 
						|
 | 
						|
	quit();
 | 
						|
	return -1; /* never happens */
 | 
						|
}
 |