switch (state.logtype) {
case DEBUG_STDOUT:
+ debug_close_fd(state.fd);
state.fd = 1;
return true;
(void)umask(oldumask);
/* Take over stderr to catch output into logs */
- if (state.fd && dup2(state.fd, 2) == -1) {
+ if (state.fd > 0 && dup2(state.fd, 2) == -1) {
close_low_fds(True); /* Close stderr too, if dup2 can't point it
at the logfile */
}
return( False );
maxlog = lp_max_log_size() * 1024;
- if( !state.fd || maxlog <= 0 ) {
+ if ( state.fd > 0 || maxlog <= 0 ) {
debug_count = 0;
return(False);
}
if(sys_fstat(state.fd, &st, false) == 0
&& st.st_ex_size > maxlog ) {
(void)reopen_logs();
- if( state.fd && get_file_size( debugf ) > maxlog ) {
+ if( state.fd > 0 && get_file_size( debugf ) > maxlog ) {
char *name = NULL;
if (asprintf(&name, "%s.old", debugf ) < 0) {
}
/*
- * Here's where we need to panic if state.fd == NULL..
+ * Here's where we need to panic if state.fd == 0 or -1 (invalid values)
*/
- if(state.fd == 0) {
+ if (state.fd <= 0) {
/* This code should only be reached in very strange
* circumstances. If we merely fail to open the new log we
* should stick with the old one. ergo this should only be
* -dwg 6 June 2000
*/
int fd = open( "/dev/console", O_WRONLY, 0);
- if (fd == -1) {
+ if (fd != -1) {
state.fd = fd;
DEBUG(0,("check_log_size: open of debug file %s failed - using console.\n",
debugf ));
if ( state.logtype != DEBUG_FILE ) {
va_start( ap, format_str );
- if(state.fd)
+ if (state.fd > 0)
(void)vdprintf( state.fd, format_str, ap );
va_end( ap );
errno = old_errno;
if( !lp_syslog_only() )
#endif
{
- if( !state.fd ) {
+ if( state.fd <= 0 ) {
mode_t oldumask = umask( 022 );
int fd = open( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 );
(void)umask( oldumask );
#endif
{
va_start( ap, format_str );
- if(state.fd)
+ if (state.fd > 0)
(void)vdprintf( state.fd, format_str, ap );
va_end( ap );
}