* 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>
* 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 *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);

View File

@ -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 ());