X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=scheduler%2Fselect.c;h=d302db0af8e7459b4b4cfa704225ca94f4f53822;hb=55516fd3bc9668b4f055220d3eb19c888f8cf1c2;hp=a44ec2e3f9a44b835e47b0c0751a319e3aae49a5;hpb=f2d18633e2916a90bbbe5ae039d1f0acc430dc0b;p=thirdparty%2Fcups.git diff --git a/scheduler/select.c b/scheduler/select.c index a44ec2e3f..d302db0af 100644 --- a/scheduler/select.c +++ b/scheduler/select.c @@ -1,28 +1,16 @@ /* * "$Id$" * - * Select abstraction functions for the CUPS scheduler. + * Select abstraction functions for the CUPS scheduler. * - * Copyright 2007-2012 by Apple Inc. - * Copyright 2006-2007 by Easy Software Products. + * Copyright 2007-2014 by Apple Inc. + * Copyright 2006-2007 by Easy Software Products. * - * These coded instructions, statements, and computer programs are the - * property of Apple Inc. and are protected by Federal copyright - * law. Distribution and use rights are outlined in the file "LICENSE.txt" - * which should have been included with this file. If this file is - * file is missing or damaged, see the license at "http://www.cups.org/". - * - * Contents: - * - * cupsdAddSelect() - Add a file descriptor to the list. - * cupsdDoSelect() - Do a select-like operation. - * cupsdIsSelecting() - Determine whether we are monitoring a file - * descriptor. - * cupsdRemoveSelect() - Remove a file descriptor from the list. - * cupsdStartSelect() - Initialize the file polling engine. - * cupsdStopSelect() - Shutdown the file polling engine. - * compare_fds() - Compare file descriptors. - * find_fd() - Find an existing file descriptor record. + * These coded instructions, statements, and computer programs are the + * property of Apple Inc. and are protected by Federal copyright + * law. Distribution and use rights are outlined in the file "LICENSE.txt" + * which should have been included with this file. If this file is + * file is missing or damaged, see the license at "http://www.cups.org/". */ /* @@ -30,7 +18,6 @@ */ #include "cupsd.h" -#undef HAVE_KQUEUE #ifdef HAVE_EPOLL # include @@ -40,8 +27,6 @@ # include #elif defined(HAVE_POLL) # include -#elif defined(__hpux) -# include #else # include #endif /* HAVE_EPOLL */ @@ -268,7 +253,7 @@ cupsdAddSelect(int fd, /* I - File descriptor */ * Range check input... */ - cupsdLogMessage(CUPSD_LOG_DEBUG, + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdAddSelect(fd=%d, read_cb=%p, write_cb=%p, data=%p)", fd, read_cb, write_cb, data); @@ -533,15 +518,13 @@ cupsdDoSelect(long timeout) /* I - Timeout in seconds */ if (cupsd_pollfds) - pfd = realloc(cupsd_pollfds, allocfds * sizeof(struct pollfd)); + pfd = realloc(cupsd_pollfds, (size_t)allocfds * sizeof(struct pollfd)); else - pfd = malloc(allocfds * sizeof(struct pollfd)); + pfd = malloc((size_t)allocfds * sizeof(struct pollfd)); if (!pfd) { - cupsdLogMessage(CUPSD_LOG_EMERG, - "Unable to allocate %d bytes for polling!", - (int)(allocfds * sizeof(struct pollfd))); + cupsdLogMessage(CUPSD_LOG_EMERG, "Unable to allocate %d bytes for polling.", (int)((size_t)allocfds * sizeof(struct pollfd))); return (-1); } @@ -570,9 +553,9 @@ cupsdDoSelect(long timeout) /* I - Timeout in seconds */ } if (timeout >= 0 && timeout < 86400) - nfds = poll(cupsd_pollfds, count, timeout * 1000); + nfds = poll(cupsd_pollfds, (nfds_t)count, timeout * 1000); else - nfds = poll(cupsd_pollfds, count, -1); + nfds = poll(cupsd_pollfds, (nfds_t)count, -1); if (nfds > 0) { @@ -723,7 +706,7 @@ cupsdRemoveSelect(int fd) /* I - File descriptor */ * Range check input... */ - cupsdLogMessage(CUPSD_LOG_DEBUG, "cupsdRemoveSelect(fd=%d)", fd); + cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdRemoveSelect(fd=%d)", fd); if (fd < 0) return; @@ -823,13 +806,13 @@ cupsdStartSelect(void) #ifdef HAVE_EPOLL cupsd_epoll_fd = epoll_create(MaxFDs); - cupsd_epoll_events = calloc(MaxFDs, sizeof(struct epoll_event)); + cupsd_epoll_events = calloc((size_t)MaxFDs, sizeof(struct epoll_event)); cupsd_update_pollfds = 0; #elif defined(HAVE_KQUEUE) cupsd_kqueue_fd = kqueue(); cupsd_kqueue_changes = 0; - cupsd_kqueue_events = calloc(MaxFDs, sizeof(struct kevent)); + cupsd_kqueue_events = calloc((size_t)MaxFDs, sizeof(struct kevent)); #elif defined(HAVE_POLL) cupsd_update_pollfds = 0;