Looping with unsigned types is safer. See the link below.
When the iterators are used for accessing an array, use size_t;
otherwise, use the most appropriate unsigned type, which in most
cases is just 'unsigned int'.
Also adjust other variables that have to interact with the
iterators, to avoid comparison of integers of different
signedness.
Link: <https://gustedt.wordpress.com/2013/07/15/a-praise-of-size_t-and-other-unsigned-types/>
Cc: Jens Gustedt <jens.gustedt@inria.fr>
Signed-off-by: Alex Colomar <alx.manpages@gmail.com>
void
consumeCpu1(int lim)
{
- for (int j = 0; j < lim; j++)
+ for (unsigned int j = 0; j < lim; j++)
getppid();
}
void
x1(void) {
- for (int j = 0; j < 100; j++)
+ for (unsigned int j = 0; j < 100; j++)
consumeCpu1(200000);
}
void
consumeCpu2(int lim)
{
- for (int j = 0; j < lim; j++)
+ for (unsigned int j = 0; j < lim; j++)
getppid();
}
void
x2(void)
{
- for (int j = 0; j < 1000; j++)
+ for (unsigned int j = 0; j < 1000; j++)
consumeCpu2(10000);
}
.EE
{
int fd;
- for (int j = 1; j < argc; j++) {
+ for (size_t j = 1; j < argc; j++) {
fd = open(argv[j], O_RDONLY);
if (fd == \-1) {
perror(argv[j]);
switch (fork()) {
case 0:
- for (int j = 1; j < argc; j++) {
+ for (size_t j = 1; j < argc; j++) {
printf("Child writing %s to efd\en", argv[j]);
u = strtoull(argv[j], NULL, 0);
/* strtoull() allows various bases */
int
main(int argc, char *argv[])
{
- for (int j = 0; j < argc; j++)
- printf("argv[%d]: %s\en", j, argv[j]);
+ for (size_t j = 0; j < argc; j++)
+ printf("argv[%zu]: %s\en", j, argv[j]);
exit(EXIT_SUCCESS);
}
int
main(int argc, char *argv[])
{
- pid_t childPid;
- int nloops;
+ pid_t childPid;
+ unsigned int nloops;
setbuf(stdout, NULL);
err(EXIT_FAILURE, "fork");
if (childPid == 0) { /* Child */
- for (int j = 0; j < nloops; j++) {
+ for (unsigned int j = 0; j < nloops; j++) {
fwait(futex1);
- printf("Child (%jd) %d\en", (intmax_t) getpid(), j);
+ printf("Child (%jd) %u\en", (intmax_t) getpid(), j);
fpost(futex2);
}
/* Parent falls through to here. */
- for (int j = 0; j < nloops; j++) {
+ for (unsigned int j = 0; j < nloops; j++) {
fwait(futex2);
- printf("Parent (%jd) %d\en", (intmax_t) getpid(), j);
+ printf("Parent (%jd) %u\en", (intmax_t) getpid(), j);
fpost(futex1);
}
printf("%d\en", mount_id);
printf("%u %d ", fhp\->handle_bytes, fhp\->handle_type);
- for (int j = 0; j < fhp\->handle_bytes; j++)
+ for (size_t j = 0; j < fhp\->handle_bytes; j++)
printf(" %02x", fhp\->f_handle[j]);
printf("\en");
fhp\->handle_type = strtoul(nextp, &nextp, 0);
- for (int j = 0; j < fhp\->handle_bytes; j++)
+ for (size_t j = 0; j < fhp\->handle_bytes; j++)
fhp\->f_handle[j] = strtoul(nextp, &nextp, 16);
/* Obtain file descriptor for mount point, either by opening
int
main(int argc, char *argv[])
{
- int nfds, num_open_fds, ready;
+ int ready;
char buf[10];
+ nfds_t num_open_fds, nfds;
ssize_t s;
struct pollfd *pfds;
/* Open each file on command line, and add it \(aqpfds\(aq array. */
- for (int j = 0; j < nfds; j++) {
+ for (nfds_t j = 0; j < nfds; j++) {
pfds[j].fd = open(argv[j + 1], O_RDONLY);
if (pfds[j].fd == \-1)
errExit("open");
/* Deal with array returned by poll(). */
- for (int j = 0; j < nfds; j++) {
+ for (nfds_t j = 0; j < nfds; j++) {
if (pfds[j].revents != 0) {
printf(" fd=%d; events: %s%s%s\en", pfds[j].fd,
(pfds[j].revents & POLLIN) ? "POLLIN " : "",
}
memset(msgs, 0, sizeof(msgs));
- for (int i = 0; i < VLEN; i++) {
+ for (size_t i = 0; i < VLEN; i++) {
iovecs[i].iov_base = bufs[i];
iovecs[i].iov_len = BUFSIZE;
msgs[i].msg_hdr.msg_iov = &iovecs[i];
}
printf("%d messages received\en", retval);
- for (int i = 0; i < retval; i++) {
+ for (size_t i = 0; i < retval; i++) {
bufs[i][msgs[i].msg_len] = 0;
- printf("%d %s", i+1, bufs[i]);
+ printf("%zu %s", i+1, bufs[i]);
}
exit(EXIT_SUCCESS);
}
{
cpu_set_t set;
int parentCPU, childCPU;
- int nloops;
+ unsigned int nloops;
if (argc != 4) {
fprintf(stderr, "Usage: %s parent\-cpu child\-cpu num\-loops\en",
if (sched_setaffinity(getpid(), sizeof(set), &set) == \-1)
err(EXIT_FAILURE, "sched_setaffinity");
- for (int j = 0; j < nloops; j++)
+ for (unsigned int j = 0; j < nloops; j++)
getppid();
exit(EXIT_SUCCESS);
if (sched_setaffinity(getpid(), sizeof(set), &set) == \-1)
err(EXIT_FAILURE, "sched_setaffinity");
- for (int j = 0; j < nloops; j++)
+ for (unsigned int j = 0; j < nloops; j++)
getppid();
wait(NULL); /* Wait for child to terminate */
main(int argc, char *argv[])
{
struct itimerspec new_value;
- int max_exp, fd;
+ int fd;
struct timespec now;
- uint64_t exp, tot_exp;
+ uint64_t exp, tot_exp, max_exp;
ssize_t s;
if (argc != 2 && argc != 4) {
int
main(int argc, char *argv[])
{
- int l;
char c;
long uffd; /* userfaultfd file descriptor */
char *addr; /* Start of region handled by userfaultfd */
- uint64_t len; /* Length 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;
main(int argc, char *argv[])
{
cpu_set_t *cpusetp;
- size_t size;
- int num_cpus;
+ size_t size, num_cpus;
if (argc < 2) {
fprintf(stderr, "Usage: %s <num\-cpus>\en", argv[0]);
size = CPU_ALLOC_SIZE(num_cpus);
CPU_ZERO_S(size, cpusetp);
- for (int cpu = 0; cpu < num_cpus; cpu += 2)
+ for (size_t cpu = 0; cpu < num_cpus; cpu += 2)
CPU_SET_S(cpu, size, cpusetp);
printf("CPU_COUNT() of set: %d\en", CPU_COUNT_S(size, cpusetp));
exit(EXIT_FAILURE);
}
- for (int j = 0; j < nptrs; j++)
+ for (size_t j = 0; j < nptrs; j++)
printf("%s\en", strings[j]);
free(strings);
main(int argc, char *argv[])
{
qsort(months, ARRAY_SIZE(months), sizeof(months[0]), compmi);
- for (int i = 1; i < argc; i++) {
+ for (size_t i = 1; i < argc; i++) {
struct mi key;
struct mi *res;
printf("Name: \e"%s\e" (%d segments)\en", info\->dlpi_name,
info\->dlpi_phnum);
- for (int j = 0; j < info\->dlpi_phnum; j++) {
+ for (size_t j = 0; j < info\->dlpi_phnum; j++) {
p_type = info\->dlpi_phdr[j].p_type;
type = (p_type == PT_LOAD) ? "PT_LOAD" :
(p_type == PT_DYNAMIC) ? "PT_DYNAMIC" :
(p_type == PT_GNU_STACK) ? "PT_GNU_STACK" :
(p_type == PT_GNU_RELRO) ? "PT_GNU_RELRO" : NULL;
- printf(" %2d: [%14p; memsz:%7jx] flags: %#jx; ", j,
+ printf(" %2zu: [%14p; memsz:%7jx] flags: %#jx; ", j,
(void *) (info\->dlpi_addr + info\->dlpi_phdr[j].p_vaddr),
(uintmax_t) info\->dlpi_phdr[j].p_memsz,
(uintmax_t) info\->dlpi_phdr[j].p_flags);
exit(EXIT_FAILURE);
}
- for (int j = 0; j < serinfo.dls_cnt; j++)
- printf("dls_serpath[%d].dls_name = %s\en",
+ for (size_t j = 0; j < serinfo.dls_cnt; j++)
+ printf("dls_serpath[%zu].dls_name = %s\en",
j, sip\->dls_serpath[j].dls_name);
exit(EXIT_SUCCESS);
char buf[64];
char txt[9];
- for (int i = 0; i < 64; i++) {
+ for (size_t i = 0; i < 64; i++) {
key[i] = rand() & 1;
}
- for (int i = 0; i < 8; i++) {
- for (int j = 0; j < 8; j++) {
+ for (size_t i = 0; i < 8; i++) {
+ for (size_t j = 0; j < 8; j++) {
buf[i * 8 + j] = orig[i] >> j & 1;
}
setkey(key);
printf("Before encrypting: %s\en", orig);
encrypt(buf, 0);
- for (int i = 0; i < 8; i++) {
- for (int j = 0, txt[i] = \(aq\e0\(aq; j < 8; j++) {
+ for (size_t i = 0; i < 8; i++) {
+ for (size_t j = 0, txt[i] = \(aq\e0\(aq; j < 8; j++) {
txt[i] |= buf[i * 8 + j] << j;
}
txt[8] = \(aq\e0\(aq;
printf("After encrypting: %s\en", txt);
encrypt(buf, 1);
- for (int i = 0; i < 8; i++) {
- for (int j = 0, txt[i] = \(aq\e0\(aq; j < 8; j++) {
+ for (size_t i = 0; i < 8; i++) {
+ for (size_t j = 0, txt[i] = \(aq\e0\(aq; j < 8; j++) {
txt[i] |= buf[i * 8 + j] << j;
}
txt[8] = \(aq\e0\(aq;
char *str;
size_t e_len = 0;
- for (int i = 0; envp[i] != NULL; i++)
+ for (size_t i = 0; envp[i] != NULL; i++)
e_len += strlen(envp[i]) + 1;
str = envz_entry(*envp, e_len, "HOME");
/* Write command\-line arguments to our file. */
- for (int j = 1; j < argc; j++)
+ for (size_t j = 1; j < argc; j++)
if (fputs(argv[j], stream) == EOF) {
perror("fputs");
exit(EXIT_FAILURE);
/* Send remaining command\-line arguments as separate
datagrams, and read responses from server. */
- for (int j = 3; j < argc; j++) {
+ for (size_t j = 3; j < argc; j++) {
len = strlen(argv[j]) + 1;
/* +1 for terminating null byte */
if (len > BUF_SIZE) {
fprintf(stderr,
- "Ignoring long message in argument %d\en", j);
+ "Ignoring long message in argument %zu\en", j);
continue;
}
exit(EXIT_FAILURE);
}
- for (int i = 0; i < argc \- 1; i++) {
+ for (size_t i = 0; i < argc \- 1; i++) {
reqs[i] = malloc(sizeof(*reqs[0]));
if (reqs[i] == NULL) {
perror("malloc");
exit(EXIT_FAILURE);
}
- for (int i = 0; i < argc \- 1; i++) {
+ for (size_t i = 0; i < argc \- 1; i++) {
printf("%s: ", reqs[i]\->ar_name);
ret = gai_error(reqs[i]);
if (ret == 0) {
#include <string.h>
static struct gaicb **reqs = NULL;
-static int nreqs = 0;
+static size_t nreqs = 0;
static char *
getcmd(void)
static void
add_requests(void)
{
- int nreqs_base = nreqs;
+ size_t nreqs_base = nreqs;
char *host;
int ret;
wait_requests(void)
{
char *id;
- int ret, n;
+ int ret;
+ size_t n;
struct gaicb const **wait_reqs = calloc(nreqs, sizeof(*wait_reqs));
/* NULL elements are ignored by gai_suspend(). */
return;
}
- for (int i = 0; i < nreqs; i++) {
+ for (size_t i = 0; i < nreqs; i++) {
if (wait_reqs[i] == NULL)
continue;
if (ret == EAI_INPROGRESS)
continue;
- printf("[%02d] %s: %s\en", i, reqs[i]\->ar_name,
+ printf("[%02zu] %s: %s\en", i, reqs[i]\->ar_name,
ret == 0 ? "Finished" : gai_strerror(ret));
}
}
cancel_requests(void)
{
char *id;
- int ret, n;
+ int ret;
+ size_t n;
while ((id = strtok(NULL, " ")) != NULL) {
n = atoi(id);
char host[NI_MAXHOST];
struct addrinfo *res;
- for (int i = 0; i < nreqs; i++) {
- printf("[%02d] %s: ", i, reqs[i]\->ar_name);
+ for (size_t i = 0; i < nreqs; i++) {
+ printf("[%02zu] %s: ", i, reqs[i]\->ar_name);
ret = gai_error(reqs[i]);
if (!ret) {
{
struct tm *tmp;
- for (int j = 1; j < argc; j++) {
+ for (size_t j = 1; j < argc; j++) {
tmp = getdate(argv[j]);
if (tmp == NULL) {
continue;
}
- printf("Call %d (\e"%s\e") succeeded:\en", j, argv[j]);
+ printf("Call %zu (\e"%s\e") succeeded:\en", j, argv[j]);
printf(" tm_sec = %d\en", tmp\->tm_sec);
printf(" tm_min = %d\en", tmp\->tm_min);
printf(" tm_hour = %d\en", tmp\->tm_hour);
if (i)
break;
printf("%s (%jd):", grpp\->gr_name, (intmax_t) grpp\->gr_gid);
- for (int j = 0; ; j++) {
+ for (size_t j = 0; ; j++) {
if (grpp\->gr_mem[j] == NULL)
break;
printf(" %s", grpp\->gr_mem[j]);
/* Display list of retrieved groups, along with group names. */
fprintf(stderr, "ngroups = %d\en", ngroups);
- for (int j = 0; j < ngroups; j++) {
+ for (size_t j = 0; j < ngroups; j++) {
printf("%d", groups[j]);
gr = getgrgid(groups[j]);
if (gr != NULL)
hcreate(30);
- for (int i = 0; i < 24; i++) {
+ for (size_t i = 0; i < 24; i++) {
e.key = data[i];
/* data is just an integer, instead of a
pointer to something */
}
}
- for (int i = 22; i < 26; i++) {
+ for (size_t i = 22; i < 26; i++) {
/* print two entries from the table, and
show that two are not in the table */
e.key = data[i];
{
#define MAX_ALLOCS 2000000
char *alloc[MAX_ALLOCS];
- int numBlocks, freeBegin, freeEnd, freeStep;
- size_t blockSize;
+ size_t blockSize, numBlocks, freeBegin, freeEnd, freeStep;
if (argc < 3 || strcmp(argv[1], "\-\-help") == 0) {
fprintf(stderr, "%s num\-blocks block\-size [free\-step "
printf("============== Before allocating blocks ==============\en");
display_mallinfo2();
- for (int j = 0; j < numBlocks; j++) {
+ for (size_t j = 0; j < numBlocks; j++) {
if (numBlocks >= MAX_ALLOCS) {
fprintf(stderr, "Too many allocations\en");
exit(EXIT_FAILURE);
printf("\en============== After allocating blocks ==============\en");
display_mallinfo2();
- for (int j = freeBegin; j < freeEnd; j += freeStep)
+ for (size_t j = freeBegin; j < freeEnd; j += freeStep)
free(alloc[j]);
printf("\en============== After freeing blocks ==============\en");
#include <stdlib.h>
#include <unistd.h>
-static size_t blockSize;
-static int numThreads, numBlocks;
+static size_t blockSize;
+static size_t numThreads;
+static unsigned int numBlocks;
static void *
thread_func(void *arg)
/* The multiplier \(aq(2 + tn)\(aq ensures that each thread (including
the main thread) allocates a different amount of memory. */
- for (int j = 0; j < numBlocks; j++)
+ for (unsigned int j = 0; j < numBlocks; j++)
if (malloc(blockSize * (2 + tn)) == NULL)
err(EXIT_FAILURE, "malloc\-thread");
/* Create threads that allocate different amounts of memory. */
- for (int tn = 0; tn < numThreads; tn++) {
+ for (size_t tn = 0; tn < numThreads; tn++) {
errno = pthread_create(&thr[tn], NULL, thread_func,
(void *) tn);
if (errno != 0)
/* The main thread also allocates some memory. */
- for (int j = 0; j < numBlocks; j++)
+ for (unsigned int j = 0; j < numBlocks; j++)
if (malloc(blockSize) == NULL)
err(EXIT_FAILURE, "malloc");
{
mtrace();
- for (int j = 0; j < 2; j++)
+ for (unsigned int j = 0; j < 2; j++)
malloc(100); /* Never freed\-\-a memory leak */
calloc(16, 16); /* Never freed\-\-a memory leak */
int
main(int argc, char *argv[])
{
- int s, opt, num_threads;
+ int s, opt;
void *res;
+ size_t num_threads;
ssize_t stack_size;
pthread_attr_t attr;
struct thread_info *tinfo;
/* Create one thread for each command\-line argument. */
- for (int tnum = 0; tnum < num_threads; tnum++) {
+ for (size_t tnum = 0; tnum < num_threads; tnum++) {
tinfo[tnum].thread_num = tnum + 1;
tinfo[tnum].argv_string = argv[optind + tnum];
/* Now join with each thread, and display its returned value. */
- for (int tnum = 0; tnum < num_threads; tnum++) {
+ for (size_t tnum = 0; tnum < num_threads; tnum++) {
s = pthread_join(tinfo[tnum].thread_id, &res);
if (s != 0)
handle_error_en(s, "pthread_join");
sleep(1);
printf("Main thread consuming some CPU time...\en");
- for (int j = 0; j < 2000000; j++)
+ for (unsigned int j = 0; j < 2000000; j++)
getppid();
pclock("Process total CPU time: ", CLOCK_PROCESS_CPUTIME_ID);
/* Set affinity mask to include CPUs 0 to 7. */
CPU_ZERO(&cpuset);
- for (int j = 0; j < 8; j++)
+ for (size_t j = 0; j < 8; j++)
CPU_SET(j, &cpuset);
s = pthread_setaffinity_np(thread, sizeof(cpuset), &cpuset);
errc(EXIT_FAILURE, s, "pthread_getaffinity_np");
printf("Set returned by pthread_getaffinity_np() contained:\en");
- for (int j = 0; j < CPU_SETSIZE; j++)
+ for (size_t j = 0; j < CPU_SETSIZE; j++)
if (CPU_ISSET(j, &cpuset))
- printf(" CPU %d\en", j);
+ printf(" CPU %zu\en", j);
exit(EXIT_SUCCESS);
}
qsort(&argv[1], argc \- 1, sizeof(char *), cmpstringp);
- for (int j = 1; j < argc; j++)
+ for (size_t j = 1; j < argc; j++)
puts(argv[j]);
exit(EXIT_SUCCESS);
}
int
main(int argc, char *argv[])
{
- int r, nloops;
- unsigned int seed;
+ int r;
+ unsigned int seed, nloops;
if (argc != 3) {
fprintf(stderr, "Usage: %s <seed> <nloops>\en", argv[0]);
nloops = atoi(argv[2]);
srand(seed);
- for (int j = 0; j < nloops; j++) {
+ for (unsigned int j = 0; j < nloops; j++) {
r = rand();
printf("%d\en", r);
}
printf("String = \e"%s\e"\en", str);
printf("Matches:\en");
- for (int i = 0; ; i++) {
+ for (unsigned int i = 0; ; i++) {
if (regexec(®ex, s, ARRAY_SIZE(pmatch), pmatch, 0))
break;
off = pmatch[0].rm_so + (s \- str);
len = pmatch[0].rm_eo \- pmatch[0].rm_so;
- printf("#%d:\en", i);
+ printf("#%zu:\en", i);
printf("offset = %jd; length = %jd\en", (intmax_t) off,
(intmax_t) len);
printf("substring = \e"%.*s\e"\en", len, s + pmatch[0].rm_so);
/* Convert data in shared memory into upper case. */
- for (int j = 0; j < shmp\->cnt; j++)
+ for (size_t j = 0; j < shmp\->cnt; j++)
shmp\->buf[j] = toupper((unsigned char) shmp\->buf[j]);
/* Post \(aqsem2\(aq to tell the peer that it can now
SLIST_REMOVE_HEAD(&head, entries); /* Deletion from the head */
free(n3);
- for (int i = 0; i < 5; i++) {
+ for (unsigned int i = 0; i < 5; i++) {
n1 = malloc(sizeof(struct entry));
SLIST_INSERT_HEAD(&head, n1, entries);
n1\->data = i;
n1 = STAILQ_FIRST(&head);
n1\->data = 0;
- for (int i = 1; i < 5; i++) {
+ for (unsigned int i = 1; i < 5; i++) {
n1 = malloc(sizeof(struct entry));
STAILQ_INSERT_HEAD(&head, n1, entries);
n1\->data = i;
base = time(NULL);
p[0] = \(aq\e0\(aq;
- for (int j = 0; j < LIM; j++) {
+ for (unsigned int j = 0; j < LIM; j++) {
if ((j % 10000) == 0)
- printf("%d %jd\en", j, (intmax_t) (time(NULL) \- base));
+ printf("%u %jd\en", j, (intmax_t) (time(NULL) \- base));
strcat(p, "a");
}
}
exit(EXIT_FAILURE);
}
- for (int j = 1; (token = strsep(&argv[1], argv[2])); j++) {
- printf("%d: %s\en", j, token);
+ for (unsigned int j = 1; (token = strsep(&argv[1], argv[2])); j++) {
+ printf("%u: %s\en", j, token);
while ((subtoken = strsep(&token, argv[3])))
printf("\et \-\-> %s\en", subtoken);
int **val;
srand(time(NULL));
- for (int i = 0; i < 12; i++) {
+ for (unsigned int i = 0; i < 12; i++) {
int *ptr = xmalloc(sizeof(*ptr));
*ptr = rand() & 0xff;
val = tsearch(ptr, &root, compare);
wordexp("[a\-c]*.c", &p, 0);
w = p.we_wordv;
- for (int i = 0; i < p.we_wordc; i++)
+ for (size_t i = 0; i < p.we_wordc; i++)
printf("%s\en", w[i]);
wordfree(&p);
exit(EXIT_SUCCESS);
pipe program. */
fprintf(fp, "argc=%d\en", argc);
- for (int j = 0; j < argc; j++)
- fprintf(fp, "argc[%d]=<%s>\en", j, argv[j]);
+ for (size_t j = 0; j < argc; j++)
+ fprintf(fp, "argc[%zu]=<%s>\en", j, argv[j]);
/* Count bytes in standard input (the core dump). */
/* Open each file specified on the command line, and queue
a read request on the resulting file descriptor. */
- for (int j = 0; j < numReqs; j++) {
+ for (size_t j = 0; j < numReqs; j++) {
ioList[j].reqNum = j;
ioList[j].status = EINPROGRESS;
ioList[j].aiocbp = &aiocbList[j];
printf("got SIGQUIT; canceling I/O requests: \en");
- for (int j = 0; j < numReqs; j++) {
+ for (size_t j = 0; j < numReqs; j++) {
if (ioList[j].status == EINPROGRESS) {
- printf(" Request %d on descriptor %d:", j,
+ printf(" Request %zu on descriptor %d:", j,
ioList[j].aiocbp\->aio_fildes);
s = aio_cancel(ioList[j].aiocbp\->aio_fildes,
ioList[j].aiocbp);
in progress. */
printf("aio_error():\en");
- for (int j = 0; j < numReqs; j++) {
+ for (size_t j = 0; j < numReqs; j++) {
if (ioList[j].status == EINPROGRESS) {
- printf(" for request %d (descriptor %d): ",
+ printf(" for request %zu (descriptor %d): ",
j, ioList[j].aiocbp\->aio_fildes);
ioList[j].status = aio_error(ioList[j].aiocbp);
/* Check status return of all I/O requests. */
printf("aio_return():\en");
- for (int j = 0; j < numReqs; j++) {
+ for (size_t j = 0; j < numReqs; j++) {
ssize_t s;
s = aio_return(ioList[j].aiocbp);
- printf(" for request %d (descriptor %d): %zd\en",
+ printf(" for request %zu (descriptor %d): %zd\en",
j, ioList[j].aiocbp\->aio_fildes, s);
}
/* Print the name of the watched directory. */
- for (int i = 1; i < argc; ++i) {
+ for (size_t i = 1; i < argc; ++i) {
if (wd[i] == event\->wd) {
printf("%s/", argv[i]);
break;
/* Send arguments. */
- for (int i = 1; i < argc; ++i) {
+ for (size_t i = 1; i < argc; ++i) {
ret = write(data_socket, argv[i], strlen(argv[i]) + 1);
if (ret == \-1) {
perror("write");
/* Replace commas in mapping string with newlines. */
map_len = strlen(mapping);
- for (int j = 0; j < map_len; j++)
+ for (size_t j = 0; j < map_len; j++)
if (mapping[j] == \(aq,\(aq)
mapping[j] = \(aq\en\(aq;