My version of patch.

Regards,
  Honza

Fabio M. Di Nitto wrote:
> Hi,
> 
> this duplicate code was giving me a fit every single time I was looking
> at it.
> 
> Make it common, static and shared between the only two callers.
> 
> At the first look this might look like a performance hit because we move
> the log_level check after the va operations but truth is that the check
> should not be there at all. It will have to be removed once log_rec is
> able to perform as we expect to record everything. At this point in time
> the check is only a workaround to make everything work.
> 
> Fabio
> 
> PS also remove the Makefile.am check since now the 2 callers are very
> small and close to each other.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Openais mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/openais

diff --git a/trunk/exec/Makefile.am b/trunk/exec/Makefile.am
index 9e931da..af8a65a 100644
--- a/trunk/exec/Makefile.am
+++ b/trunk/exec/Makefile.am
@@ -141,14 +141,3 @@ uninstall-local:
 
 clean-local:
 	rm -f corosync *.o *.lcrso gmon.out *.da *.bb *.bbg *.so*
-
-# Since we're requiring that _logsys_log_printf and _logsys_log_vprintf
-# have nearly identical code, here we require that they stay in sync.
-check_logsys_log_printf_functions:
-	$(AWK) '/^void _logsys_log_printf \(/, /^}/' $(srcdir)/logsys.c \
-	  | sed '/^[	 ]*va_/d;s/\.\.\.)$$/va_list ap)/' > $...@-1
-	$(AWK) '/^void _logsys_log_vprintf \(/, /^}/' $(srcdir)/logsys.c \
-	  | sed 's/log_vprintf/log_printf/' > $...@-2
-	diff $...@-1 $...@-2 && rm -f $...@-1 $...@-2
-
-check: check_logsys_log_printf_functions
diff --git a/trunk/exec/logsys.c b/trunk/exec/logsys.c
index 098b3fc..69fdede 100644
--- a/trunk/exec/logsys.c
+++ b/trunk/exec/logsys.c
@@ -1316,54 +1316,12 @@ void _logsys_log_printf (
 	const char *format,
 	...)
 {
-	char logsys_print_buffer[COMBINE_BUFFER_SIZE];
-	unsigned int len;
 	va_list ap;
 
-	if (subsysid <= -1) {
-		subsysid = LOGSYS_MAX_SUBSYS_COUNT;
-	}
-
-	if ((level > logsys_loggers[subsysid].syslog_priority) &&
-	    (level > logsys_loggers[subsysid].logfile_priority) &&
-	    (logsys_loggers[subsysid].debug == 0)) {
-		return;
-	}
-
 	va_start (ap, format);
-	len = vsprintf (logsys_print_buffer, format, ap);
+	_logsys_log_vprintf (subsysid, function_name, file_name, file_line,
+		level, tag, format, ap);
 	va_end (ap);
-	if (logsys_print_buffer[len - 1] == '\n') {
-		logsys_print_buffer[len - 1] = '\0';
-		len -= 1;
-	}
-
-	/*
-	 * Create a log record
-	 */
-	_logsys_log_rec (subsysid,
-		function_name,
-		file_name,
-		file_line,
-		level,
-		tag |= LOGSYS_TAG_LOG,
-		logsys_print_buffer, len + 1,
-		LOGSYS_REC_END);
-
-	if ((logsys_loggers[LOGSYS_MAX_SUBSYS_COUNT].mode & LOGSYS_MODE_THREADED) == 0) {
-		/*
-		 * Output (and block) if the log mode is not threaded otherwise
-		 * expect the worker thread to output the log data once signaled
-		 */
-		log_printf_to_logs (logsys_loggers[subsysid].subsys,
-			file_name, function_name, file_line, level, tag,
-			logsys_print_buffer);
-	} else {
-		/*
-		 * Signal worker thread to display logging output
-		 */
-		wthread_signal ();
-	}
 }
 
 int _logsys_config_subsys_get (const char *subsys)
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to