a209c3ae12
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).
54 lines
894 B
C
54 lines
894 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <string.h>
|
|
#include <err.h>
|
|
#include <stdlib.h>
|
|
|
|
#define MAX_ERROR 3
|
|
#include "common.c"
|
|
|
|
int subtest = -1;
|
|
|
|
void do_test(void)
|
|
{
|
|
int fd;
|
|
char *wbuf, *rbuf;
|
|
off_t off=0;
|
|
size_t size;
|
|
ssize_t nwritten;
|
|
ssize_t nread;
|
|
char *filename = "pwrite_test_XXXXXXX";
|
|
int i;
|
|
|
|
subtest = 1;
|
|
|
|
if ((fd = mkstemp(filename)) < 0) e(1);
|
|
|
|
size = 1 + rand() % 4096;
|
|
off = rand();
|
|
|
|
if((wbuf = malloc(sizeof(char)*size)) == NULL) e(2);
|
|
|
|
for(i = 0; i < size; i++) {
|
|
wbuf[i] = 1 + rand()%127;
|
|
}
|
|
|
|
if ((nwritten = pwrite(fd, wbuf, size, off)) < 0) e(3);
|
|
if ((rbuf = malloc(sizeof(char)*nwritten)) == NULL) e(4);
|
|
if ((nread = pread(fd, rbuf, nwritten, off)) < 0) e(5);
|
|
if (strncmp(rbuf, wbuf, nread) != 0) e(6);
|
|
|
|
close(fd);
|
|
free(wbuf);
|
|
unlink(filename);
|
|
}
|
|
|
|
|
|
int main(void)
|
|
{
|
|
start(54);
|
|
do_test();
|
|
quit();
|
|
}
|