Don't use a function named log()

This commit is contained in:
Christopher Wellons
2019-02-02 22:43:41 -05:00
parent 7fbba1e7b0
commit 8c37ff055a

View File

@@ -151,7 +151,7 @@ randline(char *line)
} }
static void static void
log(const char *format, ...) logmsg(const char *format, ...)
{ {
long long now = uepoch(); long long now = uepoch();
fprintf(stderr, "%lld.%03lld: ", now / 1000, now % 1000); fprintf(stderr, "%lld.%03lld: ", now / 1000, now % 1000);
@@ -244,7 +244,7 @@ main(int argc, char **argv)
check(listen(server, INT_MAX)); check(listen(server, INT_MAX));
if (verbose >= 1) if (verbose >= 1)
log("listen(port=%d)", port); logmsg("listen(port=%d)", port);
srand(time(0)); srand(time(0));
for (;;) { for (;;) {
@@ -265,16 +265,16 @@ main(int argc, char **argv)
/* Wait for next event */ /* Wait for next event */
if (verbose >= 2) if (verbose >= 2)
log("poll(%zu, %d)%s", pollvec->fill, timeout, logmsg("poll(%zu, %d)%s", pollvec->fill, timeout,
nclients == max_clients ? " (no accept)" : ""); nclients == max_clients ? " (no accept)" : "");
int r = poll(pollvec->fds, pollvec->fill, timeout); int r = poll(pollvec->fds, pollvec->fill, timeout);
if (verbose >= 2) if (verbose >= 2)
log("= %d", r); logmsg("= %d", r);
if (r == -1) { if (r == -1) {
switch (errno) { switch (errno) {
case EINTR: case EINTR:
if (verbose >= 1) if (verbose >= 1)
log("EINTR"); logmsg("EINTR");
continue; continue;
default: default:
fprintf(stderr, "endlessh: fatal: %s\n", strerror(errno)); fprintf(stderr, "endlessh: fatal: %s\n", strerror(errno));
@@ -286,7 +286,7 @@ main(int argc, char **argv)
if (pollvec->fds[0].revents & POLLIN) { if (pollvec->fds[0].revents & POLLIN) {
int fd = accept(server, 0, 0); int fd = accept(server, 0, 0);
if (verbose >= 1) if (verbose >= 1)
log("accept() = %d", fd); logmsg("accept() = %d", fd);
if (fd == -1) { if (fd == -1) {
const char *msg = strerror(errno); const char *msg = strerror(errno);
switch (errno) { switch (errno) {
@@ -322,7 +322,7 @@ main(int argc, char **argv)
if (revents & POLLHUP) { if (revents & POLLHUP) {
if (verbose >= 1) if (verbose >= 1)
log("close(%d)", fd); logmsg("close(%d)", fd);
close(fd); close(fd);
free(client); free(client);
nclients--; nclients--;