libtests/POSIX: Fix warnings and style.

This commit is contained in:
Joel Sherrill
2018-08-10 08:23:01 -05:00
parent b3693f5d6d
commit 382d6537df
46 changed files with 140 additions and 148 deletions

View File

@@ -15,7 +15,5 @@
int
main (void)
{
close (42);
return 0;
return close(42);
}

View File

@@ -18,7 +18,5 @@ main (void)
int oldfd = 42;
int newfd = 43;
dup2 (oldfd, newfd);
return 0;
return dup2 (oldfd, newfd);
}

View File

@@ -13,11 +13,14 @@
#include <unistd.h>
#include <fcntl.h>
int
main (void)
int main (void)
{
fcntl (42, 43);
fcntl (42, 43, 44);
int rc;
return 0;
rc = fcntl (42, 43);
(void) rc;
rc = fcntl (42, 43, 44);
return rc;
}

View File

@@ -15,6 +15,7 @@
int main(void)
{
FILE *file = NULL;
flockfile(file);
return 0;
}

View File

@@ -15,7 +15,9 @@
int
main (void)
{
fork ();
int rc;
return 0;
rc = fork();
return rc;
}

View File

@@ -12,10 +12,9 @@
#include <stdlib.h>
int
main (void)
int main (void)
{
free ((void *) 42);
free((void *) 42);
return 0;
}

View File

@@ -14,12 +14,13 @@
#include <sys/stat.h>
#include <unistd.h>
int
main (void)
int main (void)
{
struct stat buf;
int fd = 42;
fstat (fd, &buf);
int rc;
return 0;
rc = fstat(fd, &buf);
return rc;
}

View File

@@ -15,6 +15,8 @@
int main(void)
{
FILE *file = NULL;
int ret = ftrylockfile(file);
int ret;
ret = ftrylockfile(file);
return ret;
}

View File

@@ -15,6 +15,7 @@
int main(void)
{
FILE *file = NULL;
funlockfile(file);
return 0;
}

View File

@@ -12,11 +12,11 @@
#include <dirent.h>
int
main (void)
int main(void)
{
int status;
int fd = 42;
status = getdents (fd, "/tmp/foo", 0);
status = getdents(fd, "/tmp/foo", 0);
return status;
}

View File

@@ -12,11 +12,12 @@
#include <unistd.h>
int
main (void)
int main(void)
{
char *login;
login = getlogin ();
(void) login;
return 0;
}

View File

@@ -13,11 +13,11 @@
#include <sys/types.h>
#include <pwd.h>
int
main (void)
int main(void)
{
struct passwd *pass;
pass = getpwnam ("root");
return 0;
pass = getpwnam("root");
return (pass != NULL);
}

View File

@@ -13,8 +13,7 @@
#include <sys/types.h>
#include <pwd.h>
int
main (void)
int main(void)
{
struct passwd *pass;
pass = getpwnam (0);

View File

@@ -12,8 +12,7 @@
#include <sys/time.h>
int
main (void)
int main(void)
{
struct timeval tv;
struct timezone tz;

View File

@@ -13,11 +13,10 @@
#include <unistd.h>
#include <sys/types.h>
int
main (void)
int main(void)
{
uid_t uid;
uid = getuid ();
uid = getuid();
return 0;
return (uid != 0);
}

View File

@@ -12,17 +12,20 @@
#include <arpa/inet.h>
int
main (void)
int main(void)
{
uint32_t u32;
uint16_t u16;
u32 = htonl(0x12345678);
(void) u32;
u16 = htons(0x1234);
(void) u16;
u32 = ntohl(0x12345678);
(void) u32;
u16 = ntohs(0x1234);
(void) u16;
return 0;
}

View File

@@ -12,8 +12,7 @@
#include <iconv.h>
int
main (void)
int main(void)
{
iconv_t cd = NULL;
char inbuf[42];
@@ -26,5 +25,5 @@ main (void)
char *o = outbuf;
ret = iconv(cd, &i, &isize, &o, &osize);
return 0;
return ret;
}

View File

@@ -12,13 +12,12 @@
#include <iconv.h>
int
main (void)
int main(void)
{
iconv_t cd = NULL;
int ret;
ret = iconv_close(cd);
return 0;
return ret;
}

View File

@@ -12,12 +12,11 @@
#include <iconv.h>
int
main (void)
int main(void)
{
iconv_t ret;
ret = iconv_open("utf8", "ascii" );
return 0;
return (ret == 0);
}

View File

@@ -12,11 +12,10 @@
#include <unistd.h>
int
main (void)
int main(void)
{
int status;
status = issetugid ();
status = issetugid();
return 0;
return status;
}

View File

@@ -12,14 +12,18 @@
#include <signal.h>
int
main (void)
int main(void)
{
pid_t pid = 0;
int rc;
kill (pid, SIGHUP);
kill (pid, SIGKILL);
kill (pid, SIGTERM);
rc = kill(pid, SIGHUP);
(void) rc;
return 0;
rc = kill(pid, SIGKILL);
(void) rc;
rc = kill(pid, SIGTERM);
return rc;
}

View File

@@ -12,10 +12,9 @@
#include <setjmp.h>
int
main (void)
int main(void)
{
jmp_buf buf;
longjmp (buf, 0);
longjmp(buf, 0);
return 0;
}

View File

@@ -13,15 +13,19 @@
#include <sys/types.h>
#include <unistd.h>
int
main (void)
int main(void)
{
off_t res;
int fd = 42;
res = lseek (fd, 0, SEEK_SET);
res = lseek (fd, 1, SEEK_CUR);
res = lseek (fd, 2, SEEK_END);
res = lseek(fd, 0, SEEK_SET);
(void) res;
res = lseek(fd, 1, SEEK_CUR);
(void) res;
res = lseek(fd, 2, SEEK_END);
(void) res;
return 0;
}

View File

@@ -14,13 +14,12 @@
#include <sys/stat.h>
#include <unistd.h>
int
main (void)
int main(void)
{
struct stat buf;
int status;
status = lstat ("/tmp/foo", &buf);
status = lstat("/tmp/foo", &buf);
return 0;
return status;
}

View File

@@ -12,10 +12,9 @@
#include <stdlib.h>
int
main (void)
int main(void)
{
void *ptr = malloc (42);
void *ptr = malloc(42);
return (ptr != NULL);
}

View File

@@ -12,14 +12,13 @@
#include <time.h>
int
main (void)
int main(void)
{
struct timespec req = { 0, 42 };
struct timespec rem;
int status;
status = nanosleep (&req, &rem);
status = nanosleep(&req, &rem);
return 0;
return status;
}

View File

@@ -14,14 +14,13 @@
#include <sys/stat.h>
#include <fcntl.h>
int
main (void)
int main(void)
{
int fd1;
int fd2;
fd1 = open ("/tmp/foo1", O_RDWR | O_APPEND);
fd2 = open ("/tmp/foo2", O_CREAT, S_IWUSR);
fd1 = open("/tmp/foo1", O_RDWR | O_APPEND);
fd2 = open("/tmp/foo2", O_CREAT, S_IWUSR);
return 0;
return (fd1 != fd2);
}

View File

@@ -12,13 +12,12 @@
#include <unistd.h>
int
main (void)
int main(void)
{
int filedes[2];
int status;
status = pipe (filedes);
status = pipe(filedes);
return 0;
return status;
}

View File

@@ -12,11 +12,10 @@
#include <stdlib.h>
int
main (void)
int main(void)
{
void *a;
int ret = posix_memalign (&a, sizeof (void *) * 2, 42);
int ret = posix_memalign(&a, sizeof (void *) * 2, 42);
return ret;
}

View File

@@ -12,14 +12,13 @@
#include <unistd.h>
int
main (void)
int main(void)
{
int fd = 42;
char buf[4];
ssize_t len;
len = read (fd, &buf, 4);
len = read(fd, &buf, 4);
return 0;
return (len != 0);
}

View File

@@ -12,14 +12,13 @@
#include <sys/uio.h>
int
main (void)
int main(void)
{
struct iovec iov;
int count = 4;
ssize_t ret;
ret = readv (0, &iov, count);
ret = readv(0, &iov, count);
return ret;
}

View File

@@ -12,10 +12,9 @@
#include <stdlib.h>
int
main (void)
int main(void)
{
realloc (NULL, 42);
void *p = realloc(NULL, 42);
return 0;
return (p == NULL);
}

View File

@@ -12,10 +12,9 @@
#include <setjmp.h>
int
main (void)
int main(void)
{
jmp_buf buf;
setjmp (buf);
setjmp(buf);
return 0;
}

View File

@@ -12,12 +12,11 @@
#include <signal.h>
int
main (void)
int main(void)
{
sigset_t set;
int status;
status = sigaddset (&set, 21);
status = sigaddset(&set, 21);
return status;
}

View File

@@ -12,12 +12,11 @@
#include <signal.h>
int
main (void)
int main(void)
{
sigset_t set;
int status;
status = sigdelset (&set, 21);
status = sigdelset(&set, 21);
return status;
}

View File

@@ -12,11 +12,10 @@
#include <signal.h>
int
main (void)
int main(void)
{
sigset_t set;
int status = sigemptyset (&set);
int status = sigemptyset(&set);
return status;
}

View File

@@ -12,12 +12,11 @@
#include <signal.h>
int
main (void)
int main(void)
{
sigset_t set;
int status;
status = sigfillset (&set);
status = sigfillset(&set);
return status;
}

View File

@@ -12,8 +12,7 @@
#include <signal.h>
int
main (void)
int main(void)
{
sigset_t set;
int status;

View File

@@ -12,15 +12,18 @@
#include <signal.h>
int
main (void)
int main(void)
{
int status;
int rc;
sigset_t set1, set2;
status = sigprocmask (SIG_BLOCK, &set1, &set2);
status = sigprocmask (SIG_UNBLOCK, &set1, &set2);
status = sigprocmask (SIG_SETMASK, &set1, &set2);
rc = sigprocmask(SIG_BLOCK, &set1, &set2);
(void) rc;
return 0;
rc = sigprocmask(SIG_UNBLOCK, &set1, &set2);
(void) rc;
rc = sigprocmask(SIG_SETMASK, &set1, &set2);
return rc;
}

View File

@@ -14,13 +14,12 @@
#include <sys/stat.h>
#include <unistd.h>
int
main (void)
int main(void)
{
struct stat buf;
int status;
status = stat ("/tmp/foo", &buf);
status = stat("/tmp/foo", &buf);
return 0;
return status;
}

View File

@@ -16,7 +16,7 @@ int
main (void)
{
int status;
status = unlink ("/tmp/foo");
status = unlink("/tmp/foo");
return 0;
return status;
}

View File

@@ -13,11 +13,10 @@
#include <sys/types.h>
#include <unistd.h>
int
main (void)
int main(void)
{
pid_t pid;
pid = vfork ();
pid = vfork();
return 0;
return (pid != 0);
}

View File

@@ -13,12 +13,11 @@
#include <sys/types.h>
#include <sys/wait.h>
int
main (void)
int main(void)
{
int status;
pid_t pid;
pid = wait(&status);
return 0;
return (pid != 0);
}

View File

@@ -14,11 +14,11 @@
#include <sys/wait.h>
int
main (void)
main(void)
{
int status;
pid_t pid;
pid = waitpid (-1, &status, WNOHANG);
pid = waitpid(-1, &status, WNOHANG);
return 0;
return (pid != 0);
}

View File

@@ -12,14 +12,13 @@
#include <unistd.h>
int
main (void)
int main(void)
{
char string[] = "1234";
size_t count = 4;
ssize_t ret;
ret = write (0, &string, count);
ret = write(0, &string, count);
return 0;
return ret;
}

View File

@@ -12,14 +12,13 @@
#include <sys/uio.h>
int
main (void)
int main(void)
{
struct iovec iov;
int count = 4;
ssize_t ret;
ret = writev (0, &iov, count);
ret = writev(0, &iov, count);
return ret;
}