1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-11 09:50:12 +00:00

Place cancel and error under #ifdef DEBUG to mute

-Wunused-but-set-variable warnings reported by gcc 4.9

Remove some trailing whitespace as well

Tested with and without -DDEBUG

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
Enji Cooper 2015-12-28 02:01:41 +00:00
parent 8cd5a258fb
commit e26e73f37f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=292816

View File

@ -62,7 +62,10 @@ main (int argc, char *argv[])
struct kevent ke, kq_returned;
struct timespec ts;
char buffer[32768];
int cancel, error, failed = 0, fd, kq, pending, result, run;
#ifdef DEBUG
int cancel, error;
#endif
int failed = 0, fd, kq, pending, result, run;
int tmp_file = 0;
unsigned i, j;
@ -96,19 +99,19 @@ main (int argc, char *argv[])
if (iocb[i] == NULL)
err(1, "calloc");
}
pending = 0;
pending = 0;
for (i = 0; i < nitems(iocb); i++) {
pending++;
iocb[i]->aio_nbytes = sizeof(buffer);
iocb[i]->aio_buf = buffer;
iocb[i]->aio_fildes = fd;
iocb[i]->aio_offset = iocb[i]->aio_nbytes * i * run;
iocb[i]->aio_sigevent.sigev_notify_kqueue = kq;
iocb[i]->aio_sigevent.sigev_value.sival_ptr = iocb[i];
iocb[i]->aio_sigevent.sigev_notify = SIGEV_KEVENT;
result = aio_write(iocb[i]);
if (result != 0) {
perror("aio_write");
@ -133,7 +136,9 @@ main (int argc, char *argv[])
}
}
}
#ifdef DEBUG
cancel = nitems(iocb) - pending;
#endif
i = 0;
while (pending) {
@ -144,34 +149,36 @@ main (int argc, char *argv[])
bzero(&kq_returned, sizeof(ke));
ts.tv_sec = 0;
ts.tv_nsec = 1;
result = kevent(kq, NULL, 0,
result = kevent(kq, NULL, 0,
&kq_returned, 1, &ts);
#ifdef DEBUG
error = errno;
#endif
if (result < 0)
perror("kevent error: ");
kq_iocb = kq_returned.udata;
#ifdef DEBUG
printf("kevent %d %d errno %d return.ident %p "
"return.data %p return.udata %p %p\n",
i, result, error,
kq_returned.ident, kq_returned.data,
kq_returned.udata,
"return.data %p return.udata %p %p\n",
i, result, error,
kq_returned.ident, kq_returned.data,
kq_returned.udata,
kq_iocb);
#endif
if (kq_iocb)
break;
#ifdef DEBUG
printf("Try again left %d out of %d %d\n",
pending, nitems(iocb), cancel);
#endif
}
}
for (j = 0; j < nitems(iocb) && iocb[j] != kq_iocb;
j++) ;
#ifdef DEBUG
printf("kq_iocb %p\n", kq_iocb);
printf("Error Result for %d is %d pending %d\n",
j, result, pending);
#endif
@ -192,7 +199,7 @@ main (int argc, char *argv[])
iocb[j] = NULL;
pending--;
i++;
}
}
for (i = 0; i < nitems(iocb); i++)
free(iocb[i]);