Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test: fix mixed declarations warnings

  • Loading branch information...
commit 53a2c9a0831a6567385e94791e1015d67d69f79b 1 parent 3ac89ff
Ben Noordhuis bnoordhuis authored
Showing with 16 additions and 13 deletions.
  1. +15 −12 test/runner-unix.c
  2. +1 −1  test/test-spawn.c
27 test/runner-unix.c
View
@@ -63,6 +63,7 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
FILE* stdout_file;
const char* arg;
char* args[16];
+ pid_t pid;
int n;
stdout_file = tmpfile();
@@ -74,7 +75,7 @@ int process_start(char* name, char* part, process_info_t* p, int is_helper) {
p->terminated = 0;
p->status = 0;
- pid_t pid = fork();
+ pid = fork();
if (pid < 0) {
perror("fork");
@@ -162,9 +163,15 @@ static void* dowait(void* data) {
/* Time out after `timeout` msec, or never if timeout == -1 */
/* Return 0 if all processes are terminated, -1 on error, -2 on timeout. */
int process_wait(process_info_t* vec, int n, int timeout) {
- int i;
+ struct timeval tv;
process_info_t* p;
dowait_args args;
+ pthread_t tid;
+ fd_set fds;
+ int retval;
+ int i;
+ int r;
+
args.vec = vec;
args.n = n;
args.pipe[0] = -1;
@@ -182,10 +189,7 @@ int process_wait(process_info_t* vec, int n, int timeout) {
* we'd need to lock vec.
*/
- pthread_t tid;
- int retval;
-
- int r = pipe((int*)&(args.pipe));
+ r = pipe((int*)&(args.pipe));
if (r) {
perror("pipe()");
return -1;
@@ -198,11 +202,9 @@ int process_wait(process_info_t* vec, int n, int timeout) {
goto terminate;
}
- struct timeval tv;
tv.tv_sec = timeout / 1000;
tv.tv_usec = 0;
- fd_set fds;
FD_ZERO(&fds);
FD_SET(args.pipe[0], &fds);
@@ -255,15 +257,16 @@ long int process_output_size(process_info_t *p) {
/* Copy the contents of the stdio output buffer to `fd`. */
int process_copy_output(process_info_t *p, int fd) {
- int r = fseek(p->stdout_file, 0, SEEK_SET);
+ ssize_t nread, nwritten;
+ char buf[1024];
+ int r;
+
+ r = fseek(p->stdout_file, 0, SEEK_SET);
if (r < 0) {
perror("fseek");
return -1;
}
- ssize_t nread, nwritten;
- char buf[1024];
-
while ((nread = read(fileno(p->stdout_file), buf, 1024)) > 0) {
nwritten = write(fd, buf, nread);
/* TODO: what if write doesn't write the whole buffer... */
2  test/test-spawn.c
View
@@ -771,6 +771,7 @@ TEST_IMPL(environment_creation) {
#ifndef _WIN32
TEST_IMPL(spawn_setuid_setgid) {
+ struct passwd* pw;
int r;
/* if not root, then this will fail. */
@@ -783,7 +784,6 @@ TEST_IMPL(spawn_setuid_setgid) {
init_process_options("spawn_helper1", exit_cb);
/* become the "nobody" user. */
- struct passwd* pw;
pw = getpwnam("nobody");
ASSERT(pw != NULL);
options.uid = pw->pw_uid;
Please sign in to comment.
Something went wrong with that request. Please try again.