Commit d98e561a0a0ad7c711fee2a5344b6bdda76bb54c

Luke Dashjr 2012-07-23T20:15:45

Simplify code to a single vprintf path for curses-less printing

diff --git a/cgminer.c b/cgminer.c
index 6d95df9..2062397 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -164,9 +164,7 @@ static int total_threads;
 static pthread_mutex_t hash_lock;
 static pthread_mutex_t qd_lock;
 static pthread_mutex_t *stgd_lock;
-#ifdef HAVE_CURSES
 static pthread_mutex_t curses_lock;
-#endif
 static pthread_mutex_t ch_lock;
 static pthread_rwlock_t blk_lock;
 
@@ -1562,7 +1560,7 @@ void wlogprint(const char *f, ...)
 #endif
 
 #ifdef HAVE_CURSES
-void log_curses(int prio, const char *f, va_list ap)
+bool log_curses_only(int prio, const char *f, va_list ap)
 {
 	bool high_prio;
 
@@ -1577,8 +1575,9 @@ void log_curses(int prio, const char *f, va_list ap)
 			}
 		}
 		unlock_curses();
-	} else
-		vprintf(f, ap);
+		return true;
+	}
+	return false;
 }
 
 void clear_logwin(void)
diff --git a/logging.c b/logging.c
index db62374..26e0196 100644
--- a/logging.c
+++ b/logging.c
@@ -25,8 +25,8 @@ static void my_log_curses(__maybe_unused int prio, char *f, va_list ap)
 
 #ifdef HAVE_CURSES
 	extern bool use_curses;
-	if (use_curses)
-		log_curses(prio, f, ap);
+	if (use_curses && log_curses_only(prio, f, ap))
+		;
 	else
 #endif
 	{
@@ -34,11 +34,7 @@ static void my_log_curses(__maybe_unused int prio, char *f, va_list ap)
 
 		strcpy(f + len - 1, "                    \n");
 
-#ifdef HAVE_CURSES
-		log_curses(prio, f, ap);
-#else
 		vprintf(f, ap);
-#endif
 	}
 }
 
diff --git a/miner.h b/miner.h
index 76689c0..6aaa314 100644
--- a/miner.h
+++ b/miner.h
@@ -797,7 +797,7 @@ extern void switch_pools(struct pool *selected);
 extern void remove_pool(struct pool *pool);
 extern void write_config(FILE *fcfg);
 extern void default_save_file(char *filename);
-extern void log_curses(int prio, const char *f, va_list ap);
+extern bool log_curses_only(int prio, const char *f, va_list ap);
 extern void clear_logwin(void);
 extern bool pool_tclear(struct pool *pool, bool *var);
 extern struct thread_q *tq_new(void);