From a3cfd73ac9146404bc5fc4f44a832aa99749211c Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 24 Aug 2000 21:19:14 +0000 Subject: [PATCH] * select.cc (cygwin_select): Correct logic for "always_ready" fds or when there is no wait specified. * syslog.cc (pass_handler::set_message): Zero the buffer prior to setting it. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/select.cc | 5 +++-- winsup/cygwin/syslog.cc | 16 ++++++++-------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6384ba674..1167ee858 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +Thu Aug 24 17:16:14 2000 Christopher Faylor + + * select.cc (cygwin_select): Correct logic for "always_ready" fds or + when there is no wait specified. + * syslog.cc (pass_handler::set_message): Zero the buffer prior to + setting it. + 2000-08-24 Egor Duda * include/cygwin/core_dump.h: New file, contains structures used in diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 99c321b66..2b0bd2d6b 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -173,8 +173,9 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, fd_set *w = allocfd_set (maxfds); fd_set *e = allocfd_set (maxfds); - /* Don't bother waiting if one of the selected fds is "always ready". */ - if ((!sel.always_ready || ms != 0) && sel.wait (r, w, e, ms)) + if (sel.always_ready || ms == 0) + /* Don't bother waiting. */; + else if (sel.wait (r, w, e, ms)) return -1; /* some kind of error */ copyfd_set (readfds, r, maxfds); diff --git a/winsup/cygwin/syslog.cc b/winsup/cygwin/syslog.cc index 48b0d6683..233c8916e 100644 --- a/winsup/cygwin/syslog.cc +++ b/winsup/cygwin/syslog.cc @@ -71,7 +71,7 @@ openlog (const char *ident, int logopt, int facility) if (ident) { process_ident = (char *) malloc (strlen (ident) + 1); - if (process_ident == 0) + if (process_ident == NULL) { debug_printf ("failed to allocate memory for process_ident"); return; @@ -126,7 +126,7 @@ class pass_handler int print (const char *,...); int print_va (const char *, va_list); char *get_message () const { return message_; } - void set_message (char *s) { message_ = s; } + void set_message (char *s) { message_ = s; *message_ = '\0'; } }; pass_handler::pass_handler () : fp_ (0), message_ (0), total_len_ (0) @@ -179,7 +179,7 @@ pass_handler::print (const char *fmt, ...) int pass_handler::print_va (const char *fmt, va_list list) { - if (fp_ != 0) + if (fp_ != NULL) { int len = vfprintf (fp_, fmt, list); if (len < 0) @@ -187,7 +187,7 @@ pass_handler::print_va (const char *fmt, va_list list) total_len_ += len; return 0; } - else if (message_ != 0) + else if (message_ != NULL) { char *printpos = &message_[strlen (message_)]; vsprintf (printpos, fmt, list); @@ -289,7 +289,7 @@ syslog (int priority, const char *message, ...) pass.set_message ((char *) alloca (n)); /* Deal with ident_string */ - if (process_ident != 0) + if (process_ident != NULL) { if (pass.print ("%s : ", process_ident) == -1) return; @@ -340,9 +340,9 @@ syslog (int priority, const char *message, ...) if (os_being_run == winNT) { /* For NT, open the event log and send the message */ - HANDLE hEventSrc = RegisterEventSourceA (NULL, (process_ident != 0) ? + HANDLE hEventSrc = RegisterEventSourceA (NULL, (process_ident != NULL) ? process_ident : CYGWIN_LOG_NAME); - if (hEventSrc == 0) + if (hEventSrc == NULL) { debug_printf ("RegisterEventSourceA failed with %E"); return; @@ -355,7 +355,7 @@ syslog (int priority, const char *message, ...) { /* Under Windows 95, append the message to the log file */ FILE *fp = fopen (get_win95_event_log_path (), "a"); - if (fp == 0) + if (fp == NULL) { debug_printf ("failed to open file %s", get_win95_event_log_path ());