diff options
author | Alex Colomar <alx.manpages@gmail.com> | 2022-09-16 00:08:46 +0200 |
---|---|---|
committer | Alex Colomar <alx.manpages@gmail.com> | 2022-09-17 13:44:12 +0200 |
commit | 0b94bd78e52e26a5bc26d1ba2384fc875e08ccd8 (patch) | |
tree | d9444b3c5b12e01d2d166c89278da7c2680bab22 | |
parent | da3b806a84457c49f01338ada5738a07d3b51571 (diff) |
Various pages: EXAMPLES: Align variable declarations
Also, move some declarations to the top of functions.
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
42 files changed, 225 insertions, 219 deletions
diff --git a/man2/bind.2 b/man2/bind.2 index ce42aed73..a6c57bb9c 100644 --- a/man2/bind.2 +++ b/man2/bind.2 @@ -235,9 +235,9 @@ domain, and accept connections: int main(void) { - int sfd, cfd; - struct sockaddr_un my_addr, peer_addr; - socklen_t peer_addr_size; + int sfd, cfd; + socklen_t peer_addr_size; + struct sockaddr_un my_addr, peer_addr; sfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sfd == \-1) diff --git a/man2/chown.2 b/man2/chown.2 index badd3f6bc..18027233d 100644 --- a/man2/chown.2 +++ b/man2/chown.2 @@ -429,9 +429,9 @@ to perform a lookup in the system password file). int main(int argc, char *argv[]) { - uid_t uid; - struct passwd *pwd; - char *endptr; + char *endptr; + uid_t uid; + struct passwd *pwd; if (argc != 3 || argv[1][0] == \(aq\e0\(aq) { fprintf(stderr, "%s <owner> <file>\en", argv[0]); diff --git a/man2/clone.2 b/man2/clone.2 index 8b7938606..489839a47 100644 --- a/man2/clone.2 +++ b/man2/clone.2 @@ -1869,10 +1869,10 @@ childFunc(void *arg) int main(int argc, char *argv[]) { - char *stack; /* Start of stack buffer */ - char *stackTop; /* End of stack buffer */ - pid_t pid; - struct utsname uts; + char *stack; /* Start of stack buffer */ + char *stackTop; /* End of stack buffer */ + pid_t pid; + struct utsname uts; if (argc < 2) { fprintf(stderr, "Usage: %s <child\-hostname>\en", argv[0]); diff --git a/man2/copy_file_range.2 b/man2/copy_file_range.2 index 17c0fffb9..cb275055d 100644 --- a/man2/copy_file_range.2 +++ b/man2/copy_file_range.2 @@ -241,9 +241,9 @@ the call failed to copy, while still reporting success. int main(int argc, char *argv[]) { - int fd_in, fd_out; - struct stat stat; - off64_t len, ret; + int fd_in, fd_out; + off64_t len, ret; + struct stat stat; if (argc != 3) { fprintf(stderr, "Usage: %s <source> <destination>\en", argv[0]); diff --git a/man2/eventfd.2 b/man2/eventfd.2 index 8315f852c..c1b4ca99e 100644 --- a/man2/eventfd.2 +++ b/man2/eventfd.2 @@ -390,9 +390,9 @@ Parent read 28 (0x1c) from efd int main(int argc, char *argv[]) { - int efd; - uint64_t u; - ssize_t s; + int efd; + uint64_t u; + ssize_t s; if (argc < 2) { fprintf(stderr, "Usage: %s <num>...\en", argv[0]); diff --git a/man2/getdents.2 b/man2/getdents.2 index 39f658b3c..5b94674ef 100644 --- a/man2/getdents.2 +++ b/man2/getdents.2 @@ -272,11 +272,11 @@ struct linux_dirent { int main(int argc, char *argv[]) { - int fd; - long nread; - char buf[BUF_SIZE]; - struct linux_dirent *d; - char d_type; + int fd; + char d_type; + char buf[BUF_SIZE]; + long nread; + struct linux_dirent *d; fd = open(argc > 1 ? argv[1] : ".", O_RDONLY | O_DIRECTORY); if (fd == \-1) diff --git a/man2/getrlimit.2 b/man2/getrlimit.2 index c1f3a0727..69e756643 100644 --- a/man2/getrlimit.2 +++ b/man2/getrlimit.2 @@ -787,9 +787,9 @@ The program below demonstrates the use of int main(int argc, char *argv[]) { - struct rlimit old, new; - struct rlimit *newp; - pid_t pid; + pid_t pid; + struct rlimit old, new; + struct rlimit *newp; if (!(argc == 2 || argc == 4)) { fprintf(stderr, "Usage: %s <pid> [<new\-soft\-limit> " diff --git a/man2/ioctl_fat.2 b/man2/ioctl_fat.2 index fc657ffa9..b174158ce 100644 --- a/man2/ioctl_fat.2 +++ b/man2/ioctl_fat.2 @@ -266,8 +266,8 @@ Archive flag is not set static uint32_t readattr(int fd) { - uint32_t attr; - int ret; + int ret; + uint32_t attr; ret = ioctl(fd, FAT_IOCTL_GET_ATTRIBUTES, &attr); if (ret == \-1) { @@ -286,9 +286,9 @@ readattr(int fd) int main(int argc, char *argv[]) { - uint32_t attr; - int fd; - int ret; + int fd; + int ret; + uint32_t attr; if (argc != 2) { printf("Usage: %s FILENAME\en", argv[0]); @@ -362,9 +362,9 @@ Volume ID 6443\-6241 int main(int argc, char *argv[]) { - uint32_t id; - int fd; - int ret; + int fd; + int ret; + uint32_t id; if (argc != 2) { printf("Usage: %s FILENAME\en", argv[0]); @@ -430,9 +430,9 @@ LOWER.TXT \-> \(aqlower.txt\(aq int main(int argc, char *argv[]) { - struct __fat_dirent entry[2]; - int fd; - int ret; + int fd; + int ret; + struct __fat_dirent entry[2]; if (argc != 2) { printf("Usage: %s DIRECTORY\en", argv[0]); diff --git a/man2/ioctl_ns.2 b/man2/ioctl_ns.2 index 02c1dab11..08205ca3f 100644 --- a/man2/ioctl_ns.2 +++ b/man2/ioctl_ns.2 @@ -250,8 +250,8 @@ The owning user namespace is outside your namespace scope int main(int argc, char *argv[]) { - int fd, userns_fd, parent_fd; - struct stat sb; + int fd, userns_fd, parent_fd; + struct stat sb; if (argc < 2) { fprintf(stderr, "Usage: %s /proc/[pid]/ns/[file] [p|u]\en", diff --git a/man2/kcmp.2 b/man2/kcmp.2 index 0c5b891f5..d6bfb0908 100644 --- a/man2/kcmp.2 +++ b/man2/kcmp.2 @@ -369,8 +369,8 @@ test_kcmp(char *msg, pid_t pid1, pid_t pid2, int fd_a, int fd_b) int main(void) { - int fd1, fd2, fd3; - char pathname[] = "/tmp/kcmp.test"; + int fd1, fd2, fd3; + char pathname[] = "/tmp/kcmp.test"; fd1 = open(pathname, O_CREAT | O_RDWR, 0600); if (fd1 == \-1) diff --git a/man2/keyctl.2 b/man2/keyctl.2 index 2b57b5e12..59043cba1 100644 --- a/man2/keyctl.2 +++ b/man2/keyctl.2 @@ -2090,17 +2090,17 @@ $ \fBcat /proc/keys | egrep \(aqmykey|256e6a6\(aq\fP int main(int argc, char *argv[]) { - FILE *fp; - time_t t; - char *operation; - key_serial_t key_to_instantiate, dest_keyring; - key_serial_t thread_keyring, process_keyring, session_keyring; - uid_t uid; - gid_t gid; - char dbuf[256]; - char auth_key_payload[256]; - int akp_size; /* Size of auth_key_payload */ - int auth_key; + int akp_size; /* Size of auth_key_payload */ + int auth_key; + char dbuf[256]; + char auth_key_payload[256]; + char *operation; + FILE *fp; + gid_t gid; + uid_t uid; + time_t t; + key_serial_t key_to_instantiate, dest_keyring; + key_serial_t thread_keyring, process_keyring, session_keyring; if (argc != 8) { fprintf(stderr, "Usage: %s op key uid gid thread_keyring " diff --git a/man2/listxattr.2 b/man2/listxattr.2 index 3fd727359..885e6f007 100644 --- a/man2/listxattr.2 +++ b/man2/listxattr.2 @@ -204,8 +204,8 @@ user.empty: <no value> int main(int argc, char *argv[]) { - ssize_t buflen, keylen, vallen; - char *buf, *key, *val; + char *buf, *key, *val; + ssize_t buflen, keylen, vallen; if (argc != 2) { fprintf(stderr, "Usage: %s path\en", argv[0]); diff --git a/man2/memfd_create.2 b/man2/memfd_create.2 index 636fc1ffa..2668a79d8 100644 --- a/man2/memfd_create.2 +++ b/man2/memfd_create.2 @@ -422,10 +422,10 @@ Existing seals: WRITE SHRINK int main(int argc, char *argv[]) { - int fd; - unsigned int seals; - char *name, *seals_arg; - ssize_t len; + int fd; + char *name, *seals_arg; + ssize_t len; + unsigned int seals; if (argc < 3) { fprintf(stderr, "%s name size [seals]\en", argv[0]); @@ -504,8 +504,8 @@ main(int argc, char *argv[]) int main(int argc, char *argv[]) { - int fd; - unsigned int seals; + int fd; + unsigned int seals; if (argc != 2) { fprintf(stderr, "%s /proc/PID/fd/FD\en", argv[0]); diff --git a/man2/mmap.2 b/man2/mmap.2 index afe573d76..1876ae881 100644 --- a/man2/mmap.2 +++ b/man2/mmap.2 @@ -945,12 +945,12 @@ to output the desired bytes. int main(int argc, char *argv[]) { - char *addr; - int fd; - struct stat sb; - off_t offset, pa_offset; - size_t length; - ssize_t s; + int fd; + char *addr; + off_t offset, pa_offset; + size_t length; + ssize_t s; + struct stat sb; if (argc < 3 || argc > 4) { fprintf(stderr, "%s file offset [length]\en", argv[0]); diff --git a/man2/mount_setattr.2 b/man2/mount_setattr.2 index 56fe87492..f79bcfce5 100644 --- a/man2/mount_setattr.2 +++ b/man2/mount_setattr.2 @@ -952,11 +952,11 @@ static const struct option longopts[] = { int main(int argc, char *argv[]) { - struct mount_attr *attr = &(struct mount_attr){}; - int fd_userns = \-1; - bool recursive = false; - int index = 0; - int ret; + int fd_userns = \-1; + int index = 0; + int ret; + bool recursive = false; + struct mount_attr *attr = &(struct mount_attr){}; while ((ret = getopt_long_only(argc, argv, "", longopts, &index)) != \-1) { diff --git a/man2/mprotect.2 b/man2/mprotect.2 index f99c5b45c..90f928acd 100644 --- a/man2/mprotect.2 +++ b/man2/mprotect.2 @@ -316,8 +316,8 @@ handler(int sig, siginfo_t *si, void *unused) int main(void) { - int pagesize; - struct sigaction sa; + int pagesize; + struct sigaction sa; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); diff --git a/man2/msgop.2 b/man2/msgop.2 index b9b0321c4..c529a5b36 100644 --- a/man2/msgop.2 +++ b/man2/msgop.2 @@ -591,8 +591,8 @@ usage(char *prog_name, char *msg) static void send_msg(int qid, int msgtype) { - struct msgbuf msg; - time_t t; + time_t t; + struct msgbuf msg; msg.mtype = msgtype; @@ -629,10 +629,10 @@ get_msg(int qid, int msgtype) int main(int argc, char *argv[]) { - int qid, opt; - int mode = 0; /* 1 = send, 2 = receive */ - int msgtype = 1; - int msgkey = 1234; + int qid, opt; + int mode = 0; /* 1 = send, 2 = receive */ + int msgtype = 1; + int msgkey = 1234; while ((opt = getopt(argc, argv, "srt:k:")) != \-1) { switch (opt) { diff --git a/man2/open_by_handle_at.2 b/man2/open_by_handle_at.2 index 48d07fde7..36838fc29 100644 --- a/man2/open_by_handle_at.2 +++ b/man2/open_by_handle_at.2 @@ -537,9 +537,9 @@ open_by_handle_at: Stale NFS file handle int main(int argc, char *argv[]) { - struct file_handle *fhp; - int mount_id, fhsize, flags, dirfd; - char *pathname; + int mount_id, fhsize, flags, dirfd; + char *pathname; + struct file_handle *fhp; if (argc != 2) { fprintf(stderr, "Usage: %s pathname\en", argv[0]); @@ -616,12 +616,12 @@ main(int argc, char *argv[]) static int open_mount_path_by_id(int mount_id) { - char *linep; - size_t lsize; - char mount_path[PATH_MAX]; - int mi_mount_id, found; - ssize_t nread; - FILE *fp; + int mi_mount_id, found; + char mount_path[PATH_MAX]; + char *linep; + FILE *fp; + size_t lsize; + ssize_t nread; fp = fopen("/proc/self/mountinfo", "r"); if (fp == NULL) @@ -659,13 +659,13 @@ open_mount_path_by_id(int mount_id) int main(int argc, char *argv[]) { - struct file_handle *fhp; - int mount_id, fd, mount_fd, handle_bytes; - ssize_t nread; - char buf[1000]; + int mount_id, fd, mount_fd, handle_bytes; + char buf[1000]; #define LINE_SIZE 100 - char line1[LINE_SIZE], line2[LINE_SIZE]; - char *nextp; + char line1[LINE_SIZE], line2[LINE_SIZE]; + char *nextp; + ssize_t nread; + struct file_handle *fhp; if ((argc > 1 && strcmp(argv[1], "\-\-help") == 0) || argc > 2) { fprintf(stderr, "Usage: %s [mount\-path]\en", argv[0]); diff --git a/man2/perf_event_open.2 b/man2/perf_event_open.2 index 8186c21c7..e0db6e4b2 100644 --- a/man2/perf_event_open.2 +++ b/man2/perf_event_open.2 @@ -3749,9 +3749,9 @@ perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int main(void) { - struct perf_event_attr pe; - long long count; - int fd; + int fd; + long long count; + struct perf_event_attr pe; memset(&pe, 0, sizeof(pe)); pe.type = PERF_TYPE_HARDWARE; diff --git a/man2/pidfd_open.2 b/man2/pidfd_open.2 index fd7749cf8..c784881c0 100644 --- a/man2/pidfd_open.2 +++ b/man2/pidfd_open.2 @@ -227,8 +227,8 @@ pidfd_open(pid_t pid, unsigned int flags) int main(int argc, char *argv[]) { - struct pollfd pollfd; - int pidfd, ready; + int pidfd, ready; + struct pollfd pollfd; if (argc != 2) { fprintf(stderr, "Usage: %s <pid>\en", argv[0]); diff --git a/man2/pidfd_send_signal.2 b/man2/pidfd_send_signal.2 index 75126d9b1..cbd5129e5 100644 --- a/man2/pidfd_send_signal.2 +++ b/man2/pidfd_send_signal.2 @@ -189,9 +189,9 @@ pidfd_send_signal(int pidfd, int sig, siginfo_t *info, int main(int argc, char *argv[]) { - siginfo_t info; - char path[PATH_MAX]; - int pidfd, sig; + int pidfd, sig; + char path[PATH_MAX]; + siginfo_t info; if (argc != 3) { fprintf(stderr, "Usage: %s <pid> <signal>\en", argv[0]); diff --git a/man2/pipe.2 b/man2/pipe.2 index 3fc2f95fe..1a4210060 100644 --- a/man2/pipe.2 +++ b/man2/pipe.2 @@ -248,9 +248,9 @@ and echoes it on standard output. int main(int argc, char *argv[]) { - int pipefd[2]; - pid_t cpid; - char buf; + int pipefd[2]; + char buf; + pid_t cpid; if (argc != 2) { fprintf(stderr, "Usage: %s <string>\en", argv[0]); diff --git a/man2/pivot_root.2 b/man2/pivot_root.2 index 914781810..f2df25d12 100644 --- a/man2/pivot_root.2 +++ b/man2/pivot_root.2 @@ -328,10 +328,10 @@ pivot_root(const char *new_root, const char *put_old) static int /* Startup function for cloned child */ child(void *arg) { - char **args = arg; - char *new_root = args[0]; - const char *put_old = "/oldrootfs"; - char path[PATH_MAX]; + char path[PATH_MAX]; + char **args = arg; + char *new_root = args[0]; + const char *put_old = "/oldrootfs"; /* Ensure that \(aqnew_root\(aq and its parent mount don\(aqt have shared propagation (which would cause pivot_root() to @@ -378,10 +378,12 @@ child(void *arg) int main(int argc, char *argv[]) { + char *stack; + /* Create a child process in a new mount namespace. */ - char *stack = mmap(NULL, STACK_SIZE, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, \-1, 0); + stack = mmap(NULL, STACK_SIZE, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, \-1, 0); if (stack == MAP_FAILED) err(EXIT_FAILURE, "mmap"); diff --git a/man2/process_vm_readv.2 b/man2/process_vm_readv.2 index 8a28af755..d236e3461 100644 --- a/man2/process_vm_readv.2 +++ b/man2/process_vm_readv.2 @@ -287,12 +287,12 @@ and the second 10 bytes into int main(void) { - struct iovec local[2]; - struct iovec remote[1]; - char buf1[10]; - char buf2[10]; - ssize_t nread; - pid_t pid = 10; /* PID of remote process */ + char buf1[10]; + char buf2[10]; + pid_t pid = 10; /* PID of remote process */ + ssize_t nread; + struct iovec local[2]; + struct iovec remote[1]; local[0].iov_base = buf1; local[0].iov_len = 10; diff --git a/man2/readlink.2 b/man2/readlink.2 index 9600510bc..9f48db64d 100644 --- a/man2/readlink.2 +++ b/man2/readlink.2 @@ -265,9 +265,9 @@ reports a size of zero. int main(int argc, char *argv[]) { - struct stat sb; - char *buf; - ssize_t nbytes, bufsiz; + char *buf; + ssize_t nbytes, bufsiz; + struct stat sb; if (argc != 2) { fprintf(stderr, "Usage: %s <pathname>\en", argv[0]); diff --git a/man2/readv.2 b/man2/readv.2 index 1d863b3f9..f8e9854a5 100644 --- a/man2/readv.2 +++ b/man2/readv.2 @@ -398,10 +398,10 @@ The following code sample demonstrates the use of .PP .in +4n .EX -char *str0 = "hello "; -char *str1 = "world\en"; -struct iovec iov[2]; -ssize_t nwritten; +char *str0 = "hello "; +char *str1 = "world\en"; +ssize_t nwritten; +struct iovec iov[2]; iov[0].iov_base = str0; iov[0].iov_len = strlen(str0); diff --git a/man2/recvmmsg.2 b/man2/recvmmsg.2 index 0e4117297..0590d3c4a 100644 --- a/man2/recvmmsg.2 +++ b/man2/recvmmsg.2 @@ -223,12 +223,12 @@ main(void) #define VLEN 10 #define BUFSIZE 200 #define TIMEOUT 1 - int sockfd, retval; - struct sockaddr_in addr; - struct mmsghdr msgs[VLEN]; - struct iovec iovecs[VLEN]; - char bufs[VLEN][BUFSIZE+1]; - struct timespec timeout; + int sockfd, retval; + char bufs[VLEN][BUFSIZE+1]; + struct iovec iovecs[VLEN]; + struct mmsghdr msgs[VLEN]; + struct timespec timeout; + struct sockaddr_in addr; sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == \-1) { diff --git a/man2/sched_setaffinity.2 b/man2/sched_setaffinity.2 index b4963e853..3ad5bec3b 100644 --- a/man2/sched_setaffinity.2 +++ b/man2/sched_setaffinity.2 @@ -354,9 +354,9 @@ sys 12.07 int main(int argc, char *argv[]) { - cpu_set_t set; - int parentCPU, childCPU; - unsigned int nloops; + int parentCPU, childCPU; + cpu_set_t set; + unsigned int nloops; if (argc != 4) { fprintf(stderr, "Usage: %s parent\-cpu child\-cpu num\-loops\en", diff --git a/man2/seccomp_unotify.2 b/man2/seccomp_unotify.2 index 1379f11d9..f752abaaa 100644 --- a/man2/seccomp_unotify.2 +++ b/man2/seccomp_unotify.2 @@ -1425,10 +1425,10 @@ T: terminating static int sendfd(int sockfd, int fd) { - struct msghdr msgh; - struct iovec iov; - int data; - struct cmsghdr *cmsgp; + int data; + struct iovec iov; + struct msghdr msgh; + struct cmsghdr *cmsgp; /* Allocate a char array of suitable size to hold the ancillary data. However, since this buffer is in reality a \(aqstruct cmsghdr\(aq, use a @@ -1483,10 +1483,10 @@ sendfd(int sockfd, int fd) static int recvfd(int sockfd) { - struct msghdr msgh; - struct iovec iov; - int data, fd; - ssize_t nr; + int data, fd; + ssize_t nr; + struct iovec iov; + struct msghdr msgh; /* Allocate a char buffer for the ancillary data. See the comments in sendfd() */ @@ -1582,6 +1582,8 @@ seccomp(unsigned int operation, unsigned int flags, void *args) static int installNotifyFilter(void) { + int notifyFd; + struct sock_filter filter[] = { X86_64_CHECK_ARCH_AND_LOAD_SYSCALL_NR, @@ -1603,8 +1605,8 @@ installNotifyFilter(void) /* Install the filter with the SECCOMP_FILTER_FLAG_NEW_LISTENER flag; as a result, seccomp() returns a notification file descriptor. */ - int notifyFd = seccomp(SECCOMP_SET_MODE_FILTER, - SECCOMP_FILTER_FLAG_NEW_LISTENER, &prog); + notifyFd = seccomp(SECCOMP_SET_MODE_FILTER, + SECCOMP_FILTER_FLAG_NEW_LISTENER, &prog); if (notifyFd == \-1) err(EXIT_FAILURE, "seccomp\-install\-notify\-filter"); diff --git a/man2/select.2 b/man2/select.2 index 648b0ad35..0fc075d48 100644 --- a/man2/select.2 +++ b/man2/select.2 @@ -718,9 +718,9 @@ to a local variable and passing that variable to the system call. int main(void) { - fd_set rfds; - struct timeval tv; - int retval; + int retval; + fd_set rfds; + struct timeval tv; /* Watch stdin (fd 0) to see when it has input. */ diff --git a/man2/select_tut.2 b/man2/select_tut.2 index b113996b2..5a2f1a612 100644 --- a/man2/select_tut.2 +++ b/man2/select_tut.2 @@ -354,9 +354,9 @@ static int forward_port; static int listen_socket(int listen_port) { - struct sockaddr_in addr; - int lfd; - int yes; + int lfd; + int yes; + struct sockaddr_in addr; lfd = socket(AF_INET, SOCK_STREAM, 0); if (lfd == \-1) { @@ -390,8 +390,8 @@ listen_socket(int listen_port) static int connect_socket(int connect_port, char *address) { - struct sockaddr_in addr; - int cfd; + int cfd; + struct sockaddr_in addr; cfd = socket(AF_INET, SOCK_STREAM, 0); if (cfd == \-1) { @@ -439,11 +439,14 @@ connect_socket(int connect_port, char *address) int main(int argc, char *argv[]) { - int h; - int fd1 = \-1, fd2 = \-1; - char buf1[BUF_SIZE], buf2[BUF_SIZE]; - int buf1_avail = 0, buf1_written = 0; - int buf2_avail = 0, buf2_written = 0; + int h; + int ready, nfds; + int fd1 = \-1, fd2 = \-1; + int buf1_avail = 0, buf1_written = 0; + int buf2_avail = 0, buf2_written = 0; + char buf1[BUF_SIZE], buf2[BUF_SIZE]; + fd_set readfds, writefds, exceptfds; + ssize_t nbytes; if (argc != 4) { fprintf(stderr, "Usage\en\etfwd <listen\-port> " @@ -460,9 +463,7 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); for (;;) { - int ready, nfds = 0; - ssize_t nbytes; - fd_set readfds, writefds, exceptfds; + nfds = 0; FD_ZERO(&readfds); FD_ZERO(&writefds); diff --git a/man2/semget.2 b/man2/semget.2 index 47bca9ec2..7c9f4c57b 100644 --- a/man2/semget.2 +++ b/man2/semget.2 @@ -388,8 +388,8 @@ usage(const char *pname) int main(int argc, char *argv[]) { - int semid, nsems, flags, opt; - key_t key; + int semid, nsems, flags, opt; + key_t key; flags = 0; while ((opt = getopt(argc, argv, "cx")) != \-1) { diff --git a/man2/sendmmsg.2 b/man2/sendmmsg.2 index a2e84dcff..9fa30a2a2 100644 --- a/man2/sendmmsg.2 +++ b/man2/sendmmsg.2 @@ -181,11 +181,11 @@ The contents of the first datagram originates from a pair of buffers. int main(void) { - int sockfd; - struct sockaddr_in addr; - struct mmsghdr msg[2]; - struct iovec msg1[2], msg2; - int retval; + int retval; + int sockfd; + struct iovec msg1[2], msg2; + struct mmsghdr msg[2]; + struct sockaddr_in addr; sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd == \-1) { diff --git a/man2/shmop.2 b/man2/shmop.2 index 34c570bf2..1cc667092 100644 --- a/man2/shmop.2 +++ b/man2/shmop.2 @@ -368,10 +368,10 @@ shared memory segment by the "writer". int main(void) { - int semid, shmid; - union semun arg, dummy; - struct sembuf sop; - char *addr; + int semid, shmid; + char *addr; + union semun arg, dummy; + struct sembuf sop; /* Create shared memory and semaphore set containing one semaphore. */ @@ -450,10 +450,10 @@ and then decrements the semaphore value to 0 in order to inform the int main(int argc, char *argv[]) { - int semid, shmid; - struct sembuf sop; - char *addr; - size_t len; + int semid, shmid; + char *addr; + size_t len; + struct sembuf sop; if (argc != 4) { fprintf(stderr, "Usage: %s shmid semid string\en", argv[0]); diff --git a/man2/signalfd.2 b/man2/signalfd.2 index c011404f9..9c11a32df 100644 --- a/man2/signalfd.2 +++ b/man2/signalfd.2 @@ -472,10 +472,10 @@ $ int main(void) { - sigset_t mask; - int sfd; - struct signalfd_siginfo fdsi; - ssize_t s; + int sfd; + ssize_t s; + sigset_t mask; + struct signalfd_siginfo fdsi; sigemptyset(&mask); sigaddset(&mask, SIGINT); diff --git a/man2/spu_run.2 b/man2/spu_run.2 index ec85e46c0..6792184e5 100644 --- a/man2/spu_run.2 +++ b/man2/spu_run.2 @@ -215,8 +215,8 @@ system call. int main(void) { - int context, fd, spu_status; - uint32_t instruction, npc; + int context, fd, spu_status; + uint32_t instruction, npc; context = syscall(SYS_spu_create, "/spu/example\-context", 0, 0755); if (context == \-1) diff --git a/man2/sysctl.2 b/man2/sysctl.2 index 47b9f8542..f19588474 100644 --- a/man2/sysctl.2 +++ b/man2/sysctl.2 @@ -132,10 +132,10 @@ int _sysctl(struct __sysctl_args *args); int main(void) { - struct __sysctl_args args; - char osname[OSNAMESZ]; - size_t osnamelth; - int name[] = { CTL_KERN, KERN_OSTYPE }; + int name[] = { CTL_KERN, KERN_OSTYPE }; + char osname[OSNAMESZ]; + size_t osnamelth; + struct __sysctl_args args; memset(&args, 0, sizeof(args)); args.name = name; diff --git a/man2/tee.2 b/man2/tee.2 index 85e6852a5..d3f1d4121 100644 --- a/man2/tee.2 +++ b/man2/tee.2 @@ -147,8 +147,8 @@ Tue Oct 28 10:06:00 CET 2014 int main(int argc, char *argv[]) { - int fd; - ssize_t len, slen; + int fd; + ssize_t len, slen; if (argc != 2) { fprintf(stderr, "Usage: %s <file>\en", argv[0]); diff --git a/man2/timer_create.2 b/man2/timer_create.2 index a07528ba6..a9b1373e9 100644 --- a/man2/timer_create.2 +++ b/man2/timer_create.2 @@ -369,8 +369,8 @@ Caught signal 34 static void print_siginfo(siginfo_t *si) { - timer_t *tidp; - int or; + int or; + timer_t *tidp; tidp = si\->si_value.sival_ptr; @@ -401,12 +401,12 @@ handler(int sig, siginfo_t *si, void *uc) int main(int argc, char *argv[]) { - timer_t timerid; - struct sigevent sev; - struct itimerspec its; - long long freq_nanosecs; - sigset_t mask; - struct sigaction sa; + timer_t timerid; + sigset_t mask; + long long freq_nanosecs; + struct sigevent sev; + struct sigaction sa; + struct itimerspec its; if (argc != 3) { fprintf(stderr, "Usage: %s <sleep\-secs> <freq\-nanosecs>\en", diff --git a/man2/timerfd_create.2 b/man2/timerfd_create.2 index c53c97e24..fe538e0af 100644 --- a/man2/timerfd_create.2 +++ b/man2/timerfd_create.2 @@ -606,10 +606,10 @@ a.out 3 1 100 static void print_elapsed_time(void) { - static struct timespec start; - struct timespec curr; - static int first_call = 1; - int secs, nsecs; + int secs, nsecs; + static int first_call = 1; + struct timespec curr; + static struct timespec start; if (first_call) { first_call = 0; @@ -632,11 +632,11 @@ print_elapsed_time(void) int main(int argc, char *argv[]) { - struct itimerspec new_value; - int fd; - struct timespec now; - uint64_t exp, tot_exp, max_exp; - ssize_t s; + int fd; + ssize_t s; + uint64_t exp, tot_exp, max_exp; + struct timespec now; + struct itimerspec new_value; if (argc != 2 && argc != 4) { fprintf(stderr, "%s init\-secs [interval\-secs max\-exp]\en", diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index b2ee1ed3b..4efd77634 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -768,14 +768,15 @@ static int page_size; static void * fault_handler_thread(void *arg) { - int nready; - struct pollfd pollfd; - static struct uffd_msg msg; /* Data read from userfaultfd */ - static int fault_cnt = 0; /* Number of faults so far handled */ - long uffd; /* userfaultfd file descriptor */ - static char *page = NULL; - struct uffdio_copy uffdio_copy; - ssize_t nread; + int nready; + long uffd; /* userfaultfd file descriptor */ + ssize_t nread; + struct pollfd pollfd; + struct uffdio_copy uffdio_copy; + + static int fault_cnt = 0; /* Number of faults so far handled */ + static char *page = NULL; + static struct uffd_msg msg; /* Data read from userfaultfd */ uffd = (long) arg; @@ -859,14 +860,14 @@ fault_handler_thread(void *arg) int main(int argc, char *argv[]) { - char c; - long uffd; /* userfaultfd file descriptor */ - char *addr; /* Start of region handled by userfaultfd */ - size_t len, l; /* Length of region handled by userfaultfd */ - pthread_t thr; /* ID of thread that handles page faults */ - struct uffdio_api uffdio_api; - struct uffdio_register uffdio_register; - int s; + int s; + char c; + char *addr; /* Start of region handled by userfaultfd */ + long uffd; /* userfaultfd file descriptor */ + size_t len, l; /* Length of region handled by userfaultfd */ + pthread_t thr; /* ID of thread that handles page faults */ + struct uffdio_api uffdio_api; + struct uffdio_register uffdio_register; if (argc != 2) { fprintf(stderr, "Usage: %s num\-pages\en", argv[0]); diff --git a/man2/wait.2 b/man2/wait.2 index 3a36435cb..de4c36e3c 100644 --- a/man2/wait.2 +++ b/man2/wait.2 @@ -656,8 +656,8 @@ $ int main(int argc, char *argv[]) { - pid_t cpid, w; - int wstatus; + int wstatus; + pid_t cpid, w; cpid = fork(); if (cpid == \-1) { |