selinux-testsuite: adopt a more consistent style
PATCH 1/1 selinux-testsuite: adopt a more consistent style
Do a bulk restyling effort using astyle with the following options:
astyle --options=none --lineend=linux --mode=c \
--style=linux \
--indent=force-tab=8 \
--indent-preprocessor \
--indent-col1-comments \
--min-conditional-indent=0 \
--max-instatement-indent=80 \
--pad-oper \
--align-pointer=name \
--align-reference=name \
--max-code-length=80 \
--break-after-logicalSigned-off-by Paul Moore <[email protected]>
--- tests/bounds/thread.c | 2 tests/capable_file/test_lease.c | 55 ++++++----- tests/capable_net/test_bind.c | 23 ++--- tests/capable_net/test_raw.c | 19 ++-- tests/capable_sys/test_chroot.c | 27 +++-- tests/capable_sys/test_hostname.c | 29 +++--- tests/capable_sys/test_nice.c | 17 ++- tests/capable_sys/test_rawio.c | 57 ++++++------ tests/dyntrace/child.c | 2 tests/dyntrace/parent.c | 15 ++- tests/dyntrans/parent.c | 4 - tests/execshare/child.c | 2 tests/execshare/parent.c | 18 ++-- tests/exectrace/child.c | 2 tests/exectrace/parent.c | 17 ++- tests/fdreceive/client.c | 8 +- tests/fdreceive/server.c | 16 ++- tests/file/test_fcntl.c | 89 +++++++++--------- tests/file/test_lock.c | 65 +++++++------ tests/file/test_mmap.c | 70 +++++++------- tests/file/test_mprotect.c | 83 +++++++++-------- tests/file/test_nofcntl.c | 81 ++++++++-------- tests/file/test_rw.c | 81 ++++++++-------- tests/file/test_seek.c | 57 ++++++------ tests/file/test_sigiotask.c | 178 ++++++++++++++++++------------------ tests/file/wait_io.c | 32 +++---- tests/inherit/child.c | 2 tests/inherit/parent.c | 10 +- tests/ioctl/test_ioctl.c | 87 +++++++++--------- tests/ioctl/test_noioctl.c | 120 ++++++++++++------------ tests/msg/msgctl.c | 8 +- tests/msg/msgget.c | 4 - tests/msg/msgrcv.c | 4 - tests/msg/msgsnd.c | 2 tests/nnp/execnnp.c | 5 + tests/open/append2write.c | 2 tests/open/fopen.c | 2 tests/ptrace/ptrace.c | 38 ++++---- tests/sem/semctl.c | 16 ++- tests/sem/semget.c | 2 tests/sem/semop.c | 2 tests/setnice/child.c | 30 +++--- tests/setnice/parent.c | 182 +++++++++++++++++++------------------ tests/shm/shmat.c | 6 + tests/shm/shmctl.c | 12 +- tests/shm/shmget.c | 4 - tests/sigkill/server.c | 24 ++--- tests/socket/noaccept.c | 2 tests/socket/options.c | 6 + tests/socket/sink.c | 2 tests/socket/source.c | 6 + tests/task_create/parent.c | 4 - tests/task_getpgid/source.c | 6 + tests/task_getpgid/target.c | 2 tests/task_getscheduler/source.c | 6 + tests/task_getscheduler/target.c | 2 tests/task_getsid/source.c | 6 + tests/task_getsid/target.c | 2 tests/task_setnice/target.c | 2 tests/task_setpgid/source.c | 10 +- tests/task_setscheduler/source.c | 8 +- tests/task_setscheduler/target.c | 2 tests/unix_secure/checksyscalls.c | 4 - tests/unix_secure/client.c | 14 +-- tests/unix_socket/unix_options.c | 6 + tests/unix_socket/unix_sink.c | 2 tests/unix_socket/unix_source.c | 6 + tests/wait/child.c | 2 tests/wait/parent.c | 6 + 69 files changed, 871 insertions(+), 846 deletions(-)
tests/bounds/thread.c +1 -1
@@ -56,7 +56,7 @@ int main(int argc, char *argv[])if (context_type_set (context, argv[1 ])) {fprintf (stderr,"%s: unable to set new type\n" , argv[0 ]);return 1 ; - } + }freecon (security_context); security_context =context_str (context);
tests/capable_file/test_lease.c +28 -27
62 lines not on this page · raw message
tests/capable_net/test_bind.c +12 -11
@@ -6,19 +6,20 @@/* * Test the bind() operation for a socket that is protected (< 1024). */ -int main (int argc,char **argv) { +int main (int argc,char **argv) +{ -int fd; -int aport; +int fd; +int aport; - aport =IPPORT_RESERVED -1 ; - fd =rresvport (&aport); -if (fd ==-1 ) { -perror ("test_bind:rresvport" ); -exit (1 ); - } + aport =IPPORT_RESERVED -1 ; + fd =rresvport (&aport); +if (fd ==-1 ) { +perror ("test_bind:rresvport" ); +exit (1 ); + } -close (fd); -exit (0 ); +close (fd); +exit (0 ); }
tests/capable_net/test_raw.c +10 -9
@@ -6,17 +6,18 @@/* * Test the bind() operation for a raw socket. */ -int main (int argc,char **argv) { +int main (int argc,char **argv) +{ -int fd; +int fd; - fd =socket (PF_INET ,SOCK_RAW ,IPPROTO_RAW ); -if (fd ==-1 ) { -perror ("test_raw:socket" ); -exit (1 ); - } + fd =socket (PF_INET ,SOCK_RAW ,IPPROTO_RAW ); +if (fd ==-1 ) { +perror ("test_raw:socket" ); +exit (1 ); + } -close (fd); -exit (0 ); +close (fd); +exit (0 ); }
tests/capable_sys/test_chroot.c +14 -13
@@ -3,24 +3,25 @@#include <unistd.h> /* -* Test the chroot() call on a directory whose name is given as the first +* Test the chroot() call on a directory whose name is given as the first * argument. This call will result in a CAP_SYS_CHROOT capable check. */ -int main (int argc,char **argv) { +int main (int argc,char **argv) +{ -int rc; +int rc; -if ( argc !=2 ) { -printf ("usage: %s pathname\n" , argv[0 ]); -exit (2 ); - } +if ( argc !=2 ) { +printf ("usage: %s pathname\n" , argv[0 ]); +exit (2 ); + } - rc =chroot (argv[1 ]); -if ( rc !=0 ) { -perror ("test_chroot:chroot" ); -exit (1 ); - } + rc =chroot (argv[1 ]); +if ( rc !=0 ) { +perror ("test_chroot:chroot" ); +exit (1 ); + } -exit (0 ); +exit (0 ); }
tests/capable_sys/test_hostname.c +15 -14
@@ -7,23 +7,24 @@* Test the sethostname() call. * This call will result in a CAP_SYS_ADMIN capable check. */ -int main (int argc,char **argv) { +int main (int argc,char **argv) +{ -int rc; -char buf[255 ]; +int rc; +char buf[255 ]; - rc =gethostname (buf,sizeof (buf)); -if ( rc !=0 ) { -perror ("test_sethostname:gethostname" ); -exit (2 ); - } + rc =gethostname (buf,sizeof (buf)); +if ( rc !=0 ) { +perror ("test_sethostname:gethostname" ); +exit (2 ); + } - rc =sethostname (buf,strlen (buf)); -if ( rc !=0 ) { -perror ("test_sethostname:sethostname" ); -exit (1 ); - } + rc =sethostname (buf,strlen (buf)); +if ( rc !=0 ) { +perror ("test_sethostname:sethostname" ); +exit (1 ); + } -exit (0 ); +exit (0 ); }
tests/capable_sys/test_nice.c +9 -8
@@ -7,16 +7,17 @@* Test the nice() system call. * This call will result in a CAP_SYS_NICE capable check. */ -int main (int argc,char **argv) { +int main (int argc,char **argv) +{ -int rc; +int rc; - rc =nice (-10 ); -if ( rc ==-1 ) { -perror ("test_nice:nice" ); -exit (1 ); - } + rc =nice (-10 ); +if ( rc ==-1 ) { +perror ("test_nice:nice" ); +exit (1 ); + } -exit (0 ); +exit (0 ); }
tests/capable_sys/test_rawio.c +29 -28
64 lines not on this page · raw message
tests/dyntrace/child.c +1 -1
@@ -2,7 +2,7 @@#include <stdio.h> #include <selinux/selinux.h> -int main (int argc,char **argv) +int main (int argc,char **argv) {int rc;
tests/dyntrace/parent.c +8 -7
@@ -20,7 +20,7 @@ int main(int argc, char **argv)fprintf (stderr,"usage: %s newdomain program\n" , argv[0 ]);exit (-1 ); } - + rc =getcon (&context_s);if (rc <0 ) {fprintf (stderr,"%s: unable to get my context\n" , argv[0 ]);
@@ -33,12 +33,12 @@ int main(int argc, char **argv)fprintf (stderr,"%s: unable to create context structure\n" , argv[0 ]);exit (-1 ); } - +if (context_type_set (context, argv[1 ])) {fprintf (stderr,"%s: unable to set new type\n" , argv[0 ]);exit (-1 ); } - +freecon (context_s); context_s =context_str (context);if (!context_s) {
@@ -51,7 +51,7 @@ int main(int argc, char **argv)perror ("fork" );exit (-1 ); }else if (pid ==0 ) { -signal (SIGTRAP ,SIG_IGN ); +signal (SIGTRAP ,SIG_IGN ); rc =ptrace (PTRACE_TRACEME ,0 ,0 ,0 );if (rc <0 ) {perror ("ptrace: PTRACE_TRACEME" );
@@ -86,8 +86,8 @@ repeat: }fprintf (stderr,"Child has context %s\n" , context_s);fprintf (stderr,"..Resuming the child.\n" ); - rc =ptrace (PTRACE_CONT ,pid,0 ,0 ); -if (rc <0 ){ + rc =ptrace (PTRACE_CONT , pid,0 ,0 ); +if (rc <0 ) {perror ("ptrace: PTRACE_CONT" );exit (-1 ); }
@@ -96,7 +96,8 @@ repeat:if (WIFSIGNALED (status)) {fprintf (stderr,"Child terminated by signal %d.\n" ,WTERMSIG (status)); -fprintf (stderr,"..This is consistent with a ptrace permission denial - check the audit message.\n" ); +fprintf (stderr, +"..This is consistent with a ptrace permission denial - check the audit message.\n" );exit (1 ); }
tests/dyntrans/parent.c +2 -2
@@ -31,12 +31,12 @@ int main(int argc, char **argv)fprintf (stderr,"%s: unable to create context structure\n" , argv[0 ]);exit (-1 ); } - +if (context_type_set (context, argv[1 ])) {fprintf (stderr,"%s: unable to set new type\n" , argv[0 ]);exit (-1 ); } - +freecon (context_s); context_s =context_str (context);if (!context_s) {
tests/execshare/child.c +1 -1
@@ -1,6 +1,6 @@#include <stdlib.h> -int main (void ) +int main (void ) {exit (0 ); }
tests/execshare/parent.c +10 -8
@@ -12,7 +12,7 @@int clone_fn (void *arg) {char **argv = arg; -execv (argv[3 ], argv+3 ); +execv (argv[3 ], argv +3 );perror (argv[3 ]);return -1 ; }
@@ -36,7 +36,7 @@ int main(int argc, char **argv)exit (-1 ); } - pagesize =16 *getpagesize (); + pagesize =16 *getpagesize (); page =malloc (pagesize);if (!page) {perror ("malloc" );
@@ -56,7 +56,7 @@ int main(int argc, char **argv)fprintf (stderr,"%s: unable to create context structure\n" , argv[0 ]);exit (-1 ); } - +if (context_type_set (context, argv[2 ])) {fprintf (stderr,"%s: unable to set new type\n" , argv[0 ]);exit (-1 );
@@ -78,14 +78,15 @@ int main(int argc, char **argv)#if defined(__hppa__) pid =clone (clone_fn, page, cloneflags |SIGCHLD , argv);#elif defined(__ia64__) - pid =__clone2 (clone_fn, page, pagesize, cloneflags |SIGCHLD , argv,NULL ,NULL ,NULL ); + pid =__clone2 (clone_fn, page, pagesize, cloneflags |SIGCHLD , argv,NULL ,NULL , +NULL );#else pid =clone (clone_fn, clone_stack, cloneflags |SIGCHLD , argv);#endif if (pid <0 ) {perror ("clone" );exit (-1 ); - } + } pid =wait (&status);if (pid <0 ) {
@@ -102,8 +103,8 @@ int main(int argc, char **argv)fprintf (stderr,"Child stopped by signal %d.\n" ,WSTOPSIG (status));fprintf (stderr,"..This shouldn't happen.\n" );fprintf (stderr,"..Killing the child.\n" ); - rc =kill (pid,SIGKILL ); -if (rc <0 ){ + rc =kill (pid,SIGKILL ); +if (rc <0 ) {perror ("kill" );exit (-1 ); }
@@ -112,7 +113,8 @@ int main(int argc, char **argv)if (WIFSIGNALED (status)) {fprintf (stderr,"Child terminated by signal %d.\n" ,WTERMSIG (status)); -fprintf (stderr,"..This is consistent with a share permission denial, check the audit message.\n" ); +fprintf (stderr, +"..This is consistent with a share permission denial, check the audit message.\n" );exit (1 ); }
tests/exectrace/child.c +1 -1
@@ -1,6 +1,6 @@#include <stdlib.h> -int main (void ) +int main (void ) {exit (0 ); }
tests/exectrace/parent.c +9 -8
@@ -18,7 +18,7 @@ int main(int argc, char **argv)fprintf (stderr,"usage: %s newdomain program\n" , argv[0 ]);exit (-1 ); } - + rc =getcon (&context_s);if (rc <0 ) {fprintf (stderr,"%s: unable to get my context\n" , argv[0 ]);
@@ -31,12 +31,12 @@ int main(int argc, char **argv)fprintf (stderr,"%s: unable to create context structure\n" , argv[0 ]);exit (-1 ); } - +if (context_type_set (context, argv[1 ])) {fprintf (stderr,"%s: unable to set new type\n" , argv[0 ]);exit (-1 ); } - +freecon (context_s); context_s =context_str (context);if (!context_s) {
@@ -55,13 +55,13 @@ int main(int argc, char **argv)perror ("fork" );exit (-1 ); }else if (pid ==0 ) { -signal (SIGTRAP ,SIG_IGN ); +signal (SIGTRAP ,SIG_IGN ); rc =ptrace (PTRACE_TRACEME ,0 ,0 ,0 );if (rc <0 ) {perror ("ptrace: PTRACE_TRACEME" );exit (-1 ); } -execv (argv[2 ], argv+2 ); +execv (argv[2 ], argv +2 );perror (argv[2 ]);exit (1 ); }
@@ -87,8 +87,8 @@ repeat: }fprintf (stderr,"Child has context %s\n" , context_s);fprintf (stderr,"..Resuming the child.\n" ); - rc =ptrace (PTRACE_CONT ,pid,0 ,0 ); -if (rc <0 ){ + rc =ptrace (PTRACE_CONT , pid,0 ,0 ); +if (rc <0 ) {perror ("ptrace: PTRACE_CONT" );exit (-1 ); }
@@ -97,7 +97,8 @@ repeat:if (WIFSIGNALED (status)) {fprintf (stderr,"Child terminated by signal %d.\n" ,WTERMSIG (status)); -fprintf (stderr,"..This is consistent with a ptrace permission denial - check the audit message.\n" ); +fprintf (stderr, +"..This is consistent with a ptrace permission denial - check the audit message.\n" );exit (1 ); }
tests/fdreceive/client.c +4 -4
@@ -23,7 +23,7 @@ int main(int argc, char **argv)if (argc !=3 ) {fprintf (stderr,"usage: %s testfile address\n" , argv[0 ]);exit (-1 ); - } + } myfd =open (argv[1 ],O_RDWR );if (myfd <0 ) {
@@ -49,7 +49,7 @@ int main(int argc, char **argv)printf ("client: Connected to server via %s\n" , sun.sun_path);strcpy (buf,"hello world" ); - buflen =strlen (buf)+1 ; + buflen =strlen (buf) +1 ; iov.iov_base = buf; iov.iov_len = buflen; msg.msg_name =0 ;
@@ -80,10 +80,10 @@ int main(int argc, char **argv)exit (-1 ); }printf ("client: Received reply, code=%d\n" , buf[0 ]); -if (buf[0 ]) +if (buf[0 ])printf ("client: ...This implies the descriptor was not received\n" );else printf ("client: ...This implies the descriptor was received\n" ); - +exit (buf[0 ]); }
tests/fdreceive/server.c +8 -8
@@ -29,13 +29,13 @@ int main(int argc, char **argv)if (argc !=2 ) {fprintf (stderr,"usage: %s address\n" , argv[0 ]);exit (-1 ); - } + }for (i =0 ; i <32 ; i++) {signal (i, handler); } - + s =socket (AF_UNIX ,SOCK_STREAM ,0 );if (s <0 ) {perror ("socket" );
@@ -47,7 +47,7 @@ int main(int argc, char **argv)strcpy (sun.sun_path, argv[1 ]); sunlen =strlen (sun.sun_path) +1 +sizeof (short );strcpy (my_path, sun.sun_path); - ret =bind (s, (struct sockaddr *)&sun, sunlen); + ret =bind (s, (struct sockaddr *)&sun, sunlen);if (ret <0 ) {perror ("bind" );exit (-1 );
@@ -58,10 +58,10 @@ int main(int argc, char **argv)perror ("listen" );CLEANUP_AND_EXIT ; } - +while (1 ) { sunlen =sizeof (struct sockaddr_un ); - ctrl =accept (s, (struct sockaddr *)&sun, (socklen_t *)&sunlen); + ctrl =accept (s, (struct sockaddr *)&sun, (socklen_t *)&sunlen);if (ctrl <0 ) {perror ("accept_secure" );CLEANUP_AND_EXIT ;
@@ -83,12 +83,12 @@ int main(int argc, char **argv)if (ret <0 ) {perror ("recv" );CLEANUP_AND_EXIT ; - } + } -for (cmsg =CMSG_FIRSTHDR (&msg); cmsg; cmsg =CMSG_NXTHDR (&msg,cmsg)) { +for (cmsg =CMSG_FIRSTHDR (&msg); cmsg; cmsg =CMSG_NXTHDR (&msg, cmsg)) {if (cmsg->cmsg_level ==SOL_SOCKET && cmsg->cmsg_type ==SCM_RIGHTS ) { - fdptr = (int *)CMSG_DATA (cmsg); + fdptr = (int *)CMSG_DATA (cmsg); fd = *fdptr;printf ("server: Received a descriptor, fd=%d, sending back 0\n" , fd); buf[0 ] =0 ;
tests/file/test_fcntl.c +45 -44
96 lines not on this page · raw message
tests/file/test_lock.c +33 -32
74 lines not on this page · raw message
tests/file/test_mmap.c +36 -34
80 lines not on this page · raw message
tests/file/test_mprotect.c +42 -41
92 lines not on this page · raw message
tests/file/test_nofcntl.c +41 -40
89 lines not on this page · raw message
tests/file/test_rw.c +41 -40
90 lines not on this page · raw message
tests/file/test_seek.c +29 -28
63 lines not on this page · raw message
tests/file/test_sigiotask.c +89 -89
193 lines not on this page · raw message
tests/file/wait_io.c +17 -15
@@ -6,28 +6,30 @@/* * Function to handle SIGIO. */ -static void sig_io (int signo) { -printf ("wait_io: got sigio\n" ); -exit (0 ); +static void sig_io (int signo) +{ +printf ("wait_io: got sigio\n" ); +exit (0 ); }/* * This program waits either for a SIGIO signal, or will time out. The * exit status is 'good' on the SIGIO receive, 'bad' on the timeout. */ -int main (int argc,char **argv) { +int main (int argc,char **argv) +{ -struct sigaction siga; +struct sigaction siga; -/* -* Set up signal handler for SIGIO. -*/ - siga.sa_handler = sig_io; -sigemptyset (&siga.sa_mask); - siga.sa_flags =0 ; -sigaction (SIGIO , &siga,NULL ); -sleep (5 ); -printf ("wait_io: exiting without receiving sigio\n" ); -exit (1 ); +/* +* Set up signal handler for SIGIO. +*/ + siga.sa_handler = sig_io; +sigemptyset (&siga.sa_mask); + siga.sa_flags =0 ; +sigaction (SIGIO , &siga,NULL ); +sleep (5 ); +printf ("wait_io: exiting without receiving sigio\n" ); +exit (1 ); }
tests/inherit/child.c +1 -1
@@ -4,7 +4,7 @@#include <stdlib.h> #include <string.h> -int main (int argc,char **argv) +int main (int argc,char **argv) {char buf[255 ];ssize_t bytes;
tests/inherit/parent.c +5 -5
@@ -6,7 +6,7 @@#include <selinux/selinux.h> #include <selinux/context.h> -int main (int argc,char **argv) +int main (int argc,char **argv) {char **childargv;security_context_t context_s;
@@ -30,12 +30,12 @@ int main(int argc, char **argv)fprintf (stderr,"%s: unable to create context structure\n" , argv[0 ]);exit (-1 ); } - +if (context_type_set (context, argv[1 ])) {fprintf (stderr,"%s: unable to set new type\n" , argv[0 ]);exit (-1 ); } - +freecon (context_s); context_s =context_str (context);if (!context_s) {
@@ -55,7 +55,7 @@ int main(int argc, char **argv)exit (-1 ); } - childargv =malloc (3 *sizeof (char *)); + childargv =malloc (3 *sizeof (char *));if (!childargv) {fprintf (stderr,"%s: out of memory\n" , argv[0 ]);exit (-1 );
@@ -73,7 +73,7 @@ int main(int argc, char **argv)sprintf (childargv[1 ],"%d" , fd); childargv[2 ] =NULL ; -execv (childargv[0 ],childargv); +execv (childargv[0 ], childargv);perror (childargv[0 ]);exit (-1 ); }
tests/ioctl/test_ioctl.c +44 -43
100 lines not on this page · raw message
tests/ioctl/test_noioctl.c +61 -59
134 lines not on this page · raw message
tests/msg/msgctl.c +4 -4
@@ -20,7 +20,7 @@ int main(int argc, char **argv) } } - id =msgget (key,IPC_CREAT |0444 ); + id =msgget (key,IPC_CREAT |0444 );if (id ==-1 )return 1 ;
@@ -31,14 +31,14 @@ int main(int argc, char **argv) error =msgctl (id,IPC_STAT , &buf);printf ("%d" , error); -/* +/* * Equivalent: IPC_SET * Tests: MSGQ__SETATTR */ error =msgctl (id,IPC_SET , &buf);printf (" %d" , error); - -/* + +/* * Equivalent: IPC_RMID * Tests: MSGQ__DESTROY */
tests/msg/msgget.c +2 -2
@@ -23,9 +23,9 @@ int main(int argc, char **argv) } - id =msgget (key,IPC_CREAT |perms); + id =msgget (key,IPC_CREAT | perms);if (id ==-1 ) -return 1 ; +return 1 ;printf ("msgget succeeded: key = %d, id = %d\n" , key, id);return 0 ;
tests/msg/msgrcv.c +2 -2
@@ -22,9 +22,9 @@ int main(int argc, char **argv) } } - id =msgget (key,IPC_CREAT |0777 ); + id =msgget (key,IPC_CREAT |0777 );if (id ==-1 ) -return 1 ; +return 1 ; error =msgrcv (id, &msgp,MSGMAX ,1 ,IPC_NOWAIT );printf ("msgrcv: result = %d\n" , error);
tests/msg/msgsnd.c +1 -1
@@ -23,7 +23,7 @@ int main(int argc, char **argv) } } - id =msgget (key,IPC_CREAT |0777 ); + id =msgget (key,IPC_CREAT |0777 );if (id ==-1 )return 1 ;
tests/nnp/execnnp.c +3 -2
@@ -25,7 +25,7 @@ int main(int argc, char **argv)exit (-1 ); } - nobounded = ((strcmp (argv[argc-1 ],"test_nnp_bounded_t" ) ==0 ) && + nobounded = ((strcmp (argv[argc -1 ],"test_nnp_bounded_t" ) ==0 ) && (strverscmp (uts.release,"3.18" ) <0 )); rc =prctl (PR_SET_NO_NEW_PRIVS ,1 ,0 ,0 ,0 );
@@ -51,7 +51,8 @@ int main(int argc, char **argv)if (nobounded) {if (!WEXITSTATUS (status))exit (-1 ); -printf ("%s: Kernels < v3.18 do not support bounded transitions under NNP.\n" , argv[0 ]); +printf ("%s: Kernels < v3.18 do not support bounded transitions under NNP.\n" , + argv[0 ]);/* pass the test */ exit (0 ); }
tests/open/append2write.c +1 -1
@@ -5,7 +5,7 @@#include <stdio.h> #include <stdlib.h> -int main (int argc,char **argv) +int main (int argc,char **argv) {int fd, rc;
tests/open/fopen.c +1 -1
@@ -5,7 +5,7 @@#include <stdio.h> #include <stdlib.h> -int main (int argc,char **argv) +int main (int argc,char **argv) {FILE *fp;if (argc !=3 ) {
tests/ptrace/ptrace.c +19 -19
@@ -4,24 +4,24 @@#include <sys/types.h> #include <sys/wait.h> -int main (int argc,char **argv){ -int rc; -int pid; - pid=atoi (argv[1 ]); - - rc=ptrace (PTRACE_ATTACH ,pid,0 ,0 ); - -if (rc<0 ){ -exit (1 ); - } -else { -wait (NULL ); - rc =ptrace (PTRACE_DETACH ,pid,0 ,0 ); -if (rc <0 ) { -perror ("PTRACE_DETACH" ); -exit (1 ); - } - } -exit (0 ); +int main (int argc,char **argv) +{ +int rc; +int pid; + pid =atoi (argv[1 ]); + + rc =ptrace (PTRACE_ATTACH , pid,0 ,0 ); + +if (rc <0 ) { +exit (1 ); + }else { +wait (NULL ); + rc =ptrace (PTRACE_DETACH , pid,0 ,0 ); +if (rc <0 ) { +perror ("PTRACE_DETACH" ); +exit (1 ); + } + } +exit (0 ); }
tests/sem/semctl.c +8 -8
@@ -37,7 +37,7 @@ int main(int argc, char **argv) } } - id =semget (key, num,IPC_CREAT |0777 ); + id =semget (key, num,IPC_CREAT |0777 );if (id ==-1 )return 1 ;
@@ -49,21 +49,21 @@ int main(int argc, char **argv) error =semctl (id,0 ,IPC_STAT , arg);printf ("%d" , error); -/* -* Equivalent: GETPID, GETNCNT, GETZCNT +/* +* Equivalent: GETPID, GETNCNT, GETZCNT * Tests: SEM__GETATTR */ error =semctl (id,0 ,GETPID ,NULL );printf (" %d" , error); -/* +/* * Equivalent: GETVAL, GETALL * Tests: SEM__READ */ error =semctl (id,0 ,GETVAL ,NULL );printf (" %d" , error); -/* +/* * Equivalent: SETVAL, SETALL * Tests: SEM__WRITE */
@@ -71,15 +71,15 @@ int main(int argc, char **argv) error =semctl (id,0 ,SETVAL , arg);printf (" %d" , error); -/* +/* * Equivalent: IPC_SET * Tests: SEM__SETATTR */ arg.buf = &semid_buf; error =semctl (id,0 ,IPC_SET , arg);printf (" %d" , error); - -/* + +/* * Equivalent: IPC_RMID * Tests: SEM__DESTROY */
tests/sem/semget.c +1 -1
@@ -22,7 +22,7 @@ int main(int argc, char **argv) } } - id =semget (key, num,IPC_CREAT |0777 ); + id =semget (key, num,IPC_CREAT |0777 );if (id ==-1 )return 1 ;printf ("semget succeeded: key = %d, id = %d\n" , key, id);
tests/sem/semop.c +1 -1
@@ -24,7 +24,7 @@ int main(int argc, char **argv) } } - id =semget (key, num,IPC_CREAT |0777 ); + id =semget (key, num,IPC_CREAT |0777 );if (id ==-1 )return 1 ;
tests/setnice/child.c +15 -15
@@ -2,22 +2,22 @@#include <stdlib.h> #include <stdio.h> -int main (void ) +int main (void ) { -char buf[1 ]; -int rc; +char buf[1 ]; +int rc; - buf[0 ] =0 ; - rc =write (1 , buf,sizeof buf); -if (rc <0 ) { -perror ("write" ); -exit (-1 ); - } - rc =read (0 , buf,sizeof buf); -if (rc <0 ) { -perror ("read" ); -exit (-1 ); - } -exit (0 ); + buf[0 ] =0 ; + rc =write (1 , buf,sizeof buf); +if (rc <0 ) { +perror ("write" ); +exit (-1 ); + } + rc =read (0 , buf,sizeof buf); +if (rc <0 ) { +perror ("read" ); +exit (-1 ); + } +exit (0 ); }
tests/setnice/parent.c +91 -91
186 lines not on this page · raw message
tests/shm/shmat.c +3 -3
@@ -21,12 +21,12 @@ int main(int argc, char **argv) } } - id =shmget (key,2048 ,IPC_CREAT |0777 ); + id =shmget (key,2048 ,IPC_CREAT |0777 );if (id ==-1 ) -return 1 ; +return 1 ; buf =shmat (id,0 ,0 ); - error = (buf==(void *)-1 )?-1 :0 ; + error = (buf == (void *) -1 ) ?-1 :0 ;printf ("shmat: buf=%p, returned %d\n" , buf, error);return error; }
tests/shm/shmctl.c +6 -6
@@ -21,10 +21,10 @@ int main(int argc, char **argv) } } - id =shmget (key,2048 ,IPC_CREAT |0777 ); + id =shmget (key,2048 ,IPC_CREAT |0777 );if (id ==-1 ) -return 1 ; - +return 1 ; +/* * Equivalent: IPC_STAT, SHM_STAT * Tests: SHM__GETATTR | SHM__ASSOCIATE
@@ -32,7 +32,7 @@ int main(int argc, char **argv) error =shmctl (id,IPC_STAT , &buf);printf ("%d" , error); -/* +/* * Equivalent: IPC_SET * Tests: SHM__SETATTR */
@@ -40,14 +40,14 @@ int main(int argc, char **argv)printf (" %d" , error); -/* +/* * Equivalent: SHM_LOCK, SHM_UNLOCK * Tests: SHM__LOCK */ error =shmctl (id,SHM_LOCK ,NULL );printf (" %d" , error); -/* +/* * Equivalent: IPC_RMID * Tests: SHM__DESTROY */
tests/shm/shmget.c +2 -2
@@ -19,9 +19,9 @@ int main(int argc, char **argv) } } - id =shmget (key,2048 ,IPC_CREAT |0777 ); + id =shmget (key,2048 ,IPC_CREAT |0777 );if (id ==-1 ) -return 1 ; +return 1 ;printf ("shmget succeeded: key = %d, id = %d\n" , key, id);return 0 ;
tests/sigkill/server.c +12 -12
@@ -7,18 +7,18 @@ void handler(int sig)return ; } -int main (void ) +int main (void ) { -struct sigaction sa; -int i; +struct sigaction sa; +int i; - sa.sa_handler = handler; -sigemptyset (&sa.sa_mask); - sa.sa_flags =0 ; -for (i =0 ; i <32 ; i++) { -sigaction (i, &sa,NULL ); - } - -while (1 ) - ; + sa.sa_handler = handler; +sigemptyset (&sa.sa_mask); + sa.sa_flags =0 ; +for (i =0 ; i <32 ; i++) { +sigaction (i, &sa,NULL ); + } + +while (1 ) + ; }
tests/socket/noaccept.c +1 -1
@@ -78,7 +78,7 @@ main(int argc, char **argv)printf ("Changing socket sid back to %d\n" , outsid); (void )fchsid (sock, outsid); - +printf ("remote == %d\n" , remote);shutdown (sock,2 );
tests/socket/options.c +3 -3
@@ -67,9 +67,9 @@ main(int argc, char **argv)perror ("poll: " );return -1 ; }else if (result ==0 ) { -/* -* connect is taking too long, -* it's probably not going to work +/* +* connect is taking too long, +* it's probably not going to work */ printf ("poll: no events are ready\n" );return -1 ;
tests/socket/sink.c +1 -1
@@ -80,7 +80,7 @@ main(int argc, char **argv) }while (readbytes > currentbytes) { remote = -accept (sock, (struct sockaddr *) &raddr, &rsize); +accept (sock, (struct sockaddr *) &raddr, &rsize);if (remote <0 ) {perror ("accept: " );close (sock);
tests/socket/source.c +3 -3
@@ -65,9 +65,9 @@ main(int argc, char **argv)perror ("poll: " );return -1 ; }else if (result ==0 ) { -/* -* connect is taking too long, -* it's probably not going to work +/* +* connect is taking too long, +* it's probably not going to work */ printf ("poll: no events are ready\n" );return -1 ;
tests/task_create/parent.c +2 -2
@@ -8,9 +8,9 @@ int main(void)int pid;if ((pid =fork ()) <0 ) { -perror ("fork" ); +perror ("fork" );exit (1 ); } -fprintf (stderr,"%d\n" ,pid); +fprintf (stderr,"%d\n" , pid);exit (0 ); }
tests/task_getpgid/source.c +3 -3
@@ -10,15 +10,15 @@ int main(int argc, char *argv[])pid_t pid, group_id;if (argc !=2 ) { -fprintf (stderr,"Usage: %s pid\n" ,argv[0 ]); +fprintf (stderr,"Usage: %s pid\n" , argv[0 ]);exit (-1 ); } pid = (pid_t )atol (argv[1 ]); -printf ("pid = %d \n" ,pid); +printf ("pid = %d \n" , pid);if ((group_id =getpgid (pid)) <0 ) {perror ("getpgid" );exit (1 ); } -printf ("group ID = %d\n" ,group_id); +printf ("group ID = %d\n" , group_id);exit (0 ); }
tests/task_getpgid/target.c +1 -1
@@ -1,6 +1,6 @@#include <unistd.h> -int main (void ) +int main (void ) {while (1 ) {sleep (1 );
tests/task_getscheduler/source.c +3 -3
@@ -9,15 +9,15 @@ int main(int argc, char *argv[])int policy;if (argc !=2 ) { -fprintf (stderr,"Usage: %s pid\n" ,argv[0 ]); +fprintf (stderr,"Usage: %s pid\n" , argv[0 ]);exit (-1 ); } pid = (pid_t )atol (argv[1 ]); -printf ("pid = %d \n" ,pid); +printf ("pid = %d \n" , pid);if ((policy =sched_getscheduler (pid)) <0 ) {perror ("sched_getscheduler" );exit (1 ); } -printf ("policy = %d\n" ,policy); +printf ("policy = %d\n" , policy);exit (0 ); }
tests/task_getscheduler/target.c +1 -1
@@ -1,6 +1,6 @@#include <unistd.h> -int main (void ) +int main (void ) {while (1 ) {sleep (1 );
tests/task_getsid/source.c +3 -3
@@ -10,15 +10,15 @@ int main(int argc, char *argv[])pid_t pid, session_id;if (argc !=2 ) { -fprintf (stderr,"Usage: %s pid\n" ,argv[0 ]); +fprintf (stderr,"Usage: %s pid\n" , argv[0 ]);exit (-1 ); } pid = (pid_t )atol (argv[1 ]); -printf ("pid = %d \n" ,pid); +printf ("pid = %d \n" , pid);if ((session_id =getsid (pid)) <0 ) {perror ("getsid" );exit (1 ); } -printf ("session ID = %d\n" ,session_id); +printf ("session ID = %d\n" , session_id);exit (0 ); }
tests/task_getsid/target.c +1 -1
@@ -1,6 +1,6 @@#include <unistd.h> -int main (void ) +int main (void ) {while (1 ) {sleep (1 );
tests/task_setnice/target.c +1 -1
@@ -1,6 +1,6 @@#include <unistd.h> -int main (void ) +int main (void ) {while (1 ) {sleep (1 );
tests/task_setpgid/source.c +5 -5
@@ -9,14 +9,14 @@int main (void ) {pid_t pid, group_id; - + pid =getpid ();if ((group_id =getpgid (pid)) <0 ) {perror ("getpgid" );exit (-1 ); } -printf ("Group ID = %d\n" ,group_id); -if (setpgid (pid,pid) <0 ) { +printf ("Group ID = %d\n" , group_id); +if (setpgid (pid, pid) <0 ) {perror ("setpgid" );exit (1 ); }
@@ -24,7 +24,7 @@ int main(void)perror ("getpgid" );exit (-1 ); } -printf ("Group ID = %d\n" ,group_id); -printf ("pid = %d\n" ,pid); +printf ("Group ID = %d\n" , group_id); +printf ("pid = %d\n" , pid);exit (0 ); }
tests/task_setscheduler/source.c +4 -4
@@ -10,7 +10,7 @@ int main(int argc, char *argv[])struct sched_param p;if (argc !=4 ) { -fprintf (stderr,"Usage: %s pid policy priority\n" ,argv[0 ]); +fprintf (stderr,"Usage: %s pid policy priority\n" , argv[0 ]);exit (-1 ); } pid =atol (argv[1 ]);
@@ -20,11 +20,11 @@ int main(int argc, char *argv[]) } p.sched_priority =atol (argv[3 ]);printf ("pid = %d \t policy = %d \t priority = %d\n" , - pid,policy,p.sched_priority); -if (sched_setscheduler (pid,policy,&p) <0 ) { + pid, policy, p.sched_priority); +if (sched_setscheduler (pid, policy, &p) <0 ) {perror ("sched_setscheduler" );exit (1 ); } - +exit (0 ); }
tests/task_setscheduler/target.c +1 -1
@@ -1,6 +1,6 @@#include <unistd.h> -int main (void ) +int main (void ) {while (1 ) {sleep (1 );
tests/unix_secure/checksyscalls.c +2 -2
@@ -17,8 +17,8 @@ main(int argc, char **argv)if (sock <0 ) {perror ("socket" );if (errno ==ENOSYS ) { -printf ("Extended socket system calls are unimplemented\n" ); -return -1 ; +printf ("Extended socket system calls are unimplemented\n" ); +return -1 ; }return -2 ; }
tests/unix_secure/client.c +7 -7
@@ -66,7 +66,7 @@ main(int argc, char **argv)/* printf("connect_secure with peer sid %d\n", peer_sid); */ }else { result = -connect (sock, (struct sockaddr *) &sun, sunlen); +connect (sock, (struct sockaddr *) &sun, sunlen); }if (result <0 ) {if (errno ==EINPROGRESS ) {
@@ -77,9 +77,9 @@ main(int argc, char **argv)perror ("poll: " );return -1 ; }else if (result ==0 ) { -/* -* connect is taking too long, -* it's probably not going to work +/* +* connect is taking too long, +* it's probably not going to work */ printf ("poll: no events are ready\n" );return -1 ;
@@ -110,17 +110,17 @@ main(int argc, char **argv) read_sid =atoi (data);if (read_sid != client_sid) { bad++; -/* printf("client sid %d, read back sid %d\n", +/* printf("client sid %d, read back sid %d\n", client_sid, read_sid); */ }shutdown (sock,2 );close (sock); -/* +/* * Return the number of bad connections, where the server * returned something other than the sid of this client's -* socket +* socket */ return (bad); }
tests/unix_socket/unix_options.c +3 -3
@@ -70,9 +70,9 @@ main(int argc, char **argv)perror ("poll: " );return -1 ; }else if (result ==0 ) { -/* -* connect is taking too long, -* it's probably not going to work +/* +* connect is taking too long, +* it's probably not going to work */ printf ("poll: no events are ready\n" );return -1 ;
tests/unix_socket/unix_sink.c +1 -1
@@ -86,7 +86,7 @@ main(int argc, char **argv) }while (readbytes > currentbytes) { remote = -accept (sock, (struct sockaddr *) &raddr, &rsize); +accept (sock, (struct sockaddr *) &raddr, &rsize);if (remote <0 ) {perror ("accept: " );close (sock);
tests/unix_socket/unix_source.c +3 -3
@@ -69,9 +69,9 @@ main(int argc, char **argv)perror ("poll: " );return -1 ; }else if (result ==0 ) { -/* -* connect is taking too long, -* it's probably not going to work +/* +* connect is taking too long, +* it's probably not going to work */ printf ("poll: no events are ready\n" );return -1 ;
tests/wait/child.c +1 -1
@@ -1,6 +1,6 @@#include <stdlib.h> -int main (void ) +int main (void ) {exit (0 ); }
tests/wait/parent.c +3 -3
@@ -30,12 +30,12 @@ int main(int argc, char **argv)fprintf (stderr,"%s: unable to create context structure\n" , argv[0 ]);exit (-1 ); } - +if (context_type_set (context, argv[1 ])) {fprintf (stderr,"%s: unable to set new type\n" , argv[0 ]);exit (-1 ); } - +freecon (context_s); context_s =context_str (context);if (!context_s) {
@@ -54,7 +54,7 @@ int main(int argc, char **argv)perror ("fork" );exit (-1 ); }else if (pid ==0 ) { - rc =execv (argv[2 ], argv+2 ); + rc =execv (argv[2 ], argv +2 );perror (argv[3 ]);exit (1 ); }