Simplify code to a single vprintf path for curses-less printing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
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);