On each iteration through this loop we could set err but then
continue. When we exit the loop we return an error although one that
we might have continued past. If we can continue past it should we
return it? If we return it should we just stop at that point?
mph
[...]
while ((dp = readdir(dirp)) != NULL) {
if (strncmp(dp->d_name, NWAM_EVENT_MSG_FILE,
strlen(NWAM_EVENT_MSG_FILE)) != 0)
continue;
(void) snprintf(eventmsgfile, sizeof (eventmsgfile), "%s/%s",
NWAM_EVENT_MSG_DIR, dp->d_name);
if ((key = ftok(eventmsgfile, 0)) == -1) {
err = nwam_errno_to_nwam_error(errno);
continue;
}
if ((msqid = msgget(key, 0644)) == -1) {
err = nwam_errno_to_nwam_error(errno);
continue;
}
[...a series of like statements...]
/*
* This shouldn't ever block but if it does it is catastrophic.
*/
if (msgsnd(msqid, (struct msgbuf *)event, event->size,
IPC_NOWAIT) == -1) {
assert(errno != EAGAIN);
err = nwam_errno_to_nwam_error(errno);
continue;
}
}
(void) closedir(dirp);
return (err);