* 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.
This commit is contained in:
Christopher Faylor 2000-08-24 21:19:14 +00:00
parent be8924c43b
commit a3cfd73ac9
3 changed files with 18 additions and 10 deletions

View File

@ -1,3 +1,10 @@
Thu Aug 24 17:16:14 2000 Christopher Faylor <cgf@cygnus.com>
* 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 <deo@logos-m.ru> 2000-08-24 Egor Duda <deo@logos-m.ru>
* include/cygwin/core_dump.h: New file, contains structures used in * include/cygwin/core_dump.h: New file, contains structures used in

View File

@ -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 *w = allocfd_set (maxfds);
fd_set *e = 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)
if ((!sel.always_ready || ms != 0) && sel.wait (r, w, e, ms)) /* Don't bother waiting. */;
else if (sel.wait (r, w, e, ms))
return -1; /* some kind of error */ return -1; /* some kind of error */
copyfd_set (readfds, r, maxfds); copyfd_set (readfds, r, maxfds);

View File

@ -71,7 +71,7 @@ openlog (const char *ident, int logopt, int facility)
if (ident) if (ident)
{ {
process_ident = (char *) malloc (strlen (ident) + 1); process_ident = (char *) malloc (strlen (ident) + 1);
if (process_ident == 0) if (process_ident == NULL)
{ {
debug_printf ("failed to allocate memory for process_ident"); debug_printf ("failed to allocate memory for process_ident");
return; return;
@ -126,7 +126,7 @@ class pass_handler
int print (const char *,...); int print (const char *,...);
int print_va (const char *, va_list); int print_va (const char *, va_list);
char *get_message () const { return message_; } 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) pass_handler::pass_handler () : fp_ (0), message_ (0), total_len_ (0)
@ -179,7 +179,7 @@ pass_handler::print (const char *fmt, ...)
int int
pass_handler::print_va (const char *fmt, va_list list) pass_handler::print_va (const char *fmt, va_list list)
{ {
if (fp_ != 0) if (fp_ != NULL)
{ {
int len = vfprintf (fp_, fmt, list); int len = vfprintf (fp_, fmt, list);
if (len < 0) if (len < 0)
@ -187,7 +187,7 @@ pass_handler::print_va (const char *fmt, va_list list)
total_len_ += len; total_len_ += len;
return 0; return 0;
} }
else if (message_ != 0) else if (message_ != NULL)
{ {
char *printpos = &message_[strlen (message_)]; char *printpos = &message_[strlen (message_)];
vsprintf (printpos, fmt, list); vsprintf (printpos, fmt, list);
@ -289,7 +289,7 @@ syslog (int priority, const char *message, ...)
pass.set_message ((char *) alloca (n)); pass.set_message ((char *) alloca (n));
/* Deal with ident_string */ /* Deal with ident_string */
if (process_ident != 0) if (process_ident != NULL)
{ {
if (pass.print ("%s : ", process_ident) == -1) if (pass.print ("%s : ", process_ident) == -1)
return; return;
@ -340,9 +340,9 @@ syslog (int priority, const char *message, ...)
if (os_being_run == winNT) if (os_being_run == winNT)
{ {
/* For NT, open the event log and send the message */ /* 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); process_ident : CYGWIN_LOG_NAME);
if (hEventSrc == 0) if (hEventSrc == NULL)
{ {
debug_printf ("RegisterEventSourceA failed with %E"); debug_printf ("RegisterEventSourceA failed with %E");
return; return;
@ -355,7 +355,7 @@ syslog (int priority, const char *message, ...)
{ {
/* Under Windows 95, append the message to the log file */ /* Under Windows 95, append the message to the log file */
FILE *fp = fopen (get_win95_event_log_path (), "a"); FILE *fp = fopen (get_win95_event_log_path (), "a");
if (fp == 0) if (fp == NULL)
{ {
debug_printf ("failed to open file %s", debug_printf ("failed to open file %s",
get_win95_event_log_path ()); get_win95_event_log_path ());