force type checking on curses
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
diff --git a/cgminer.c b/cgminer.c
index 022ccc3..6cea4ff 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2053,38 +2053,50 @@ static void text_print_status(int thr_id)
}
#ifdef HAVE_CURSES
+#define CURBUFSIZ 256
+#define cg_mvwprintw(win, y, x, fmt, ...) do { \
+ char tmp42[CURBUFSIZ]; \
+ snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \
+ mvwprintw(win, y, x, "%s", tmp42); \
+} while (0)
+#define cg_wprintw(win, fmt, ...) do { \
+ char tmp42[CURBUFSIZ]; \
+ snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \
+ wprintw(win, "%s", tmp42); \
+} while (0)
+
/* Must be called with curses mutex lock held and curses_active */
static void curses_print_status(void)
{
struct pool *pool = current_pool();
wattron(statuswin, A_BOLD);
- mvwprintw(statuswin, 0, 0, " " PACKAGE " version " VERSION " - Started: %s", datestamp);
+ cg_mvwprintw(statuswin, 0, 0, " " PACKAGE " version " VERSION " - Started: %s", datestamp);
wattroff(statuswin, A_BOLD);
mvwhline(statuswin, 1, 0, '-', 80);
- mvwprintw(statuswin, 2, 0, " %s", statusline);
+ cg_mvwprintw(statuswin, 2, 0, " %s", statusline);
wclrtoeol(statuswin);
- mvwprintw(statuswin, 3, 0, " ST: %d SS: %d NB: %d LW: %d GF: %d RF: %d",
+ cg_mvwprintw(statuswin, 3, 0, " ST: %d SS: %d NB: %d LW: %d GF: %d RF: %d",
total_staged(), total_stale, new_blocks,
local_work, total_go, total_ro);
wclrtoeol(statuswin);
if ((pool_strategy == POOL_LOADBALANCE || pool_strategy == POOL_BALANCE) && total_pools > 1) {
- mvwprintw(statuswin, 4, 0, " Connected to multiple pools with%s LP",
+ cg_mvwprintw(statuswin, 4, 0, " Connected to multiple pools with%s LP",
have_longpoll ? "": "out");
} else if (pool->has_stratum) {
- mvwprintw(statuswin, 4, 0, " Connected to %s diff %s with stratum as user %s",
+ cg_mvwprintw(statuswin, 4, 0, " Connected to %s diff %s with stratum as user %s",
pool->sockaddr_url, pool->diff, pool->rpc_user);
} else {
- mvwprintw(statuswin, 4, 0, " Connected to %s diff %s with%s %s as user %s",
+ cg_mvwprintw(statuswin, 4, 0, " Connected to %s diff %s with%s %s as user %s",
pool->sockaddr_url, pool->diff, have_longpoll ? "": "out",
pool->has_gbt ? "GBT" : "LP", pool->rpc_user);
}
wclrtoeol(statuswin);
- mvwprintw(statuswin, 5, 0, " Block: %s... Diff:%s Started: %s Best share: %s ",
+ cg_mvwprintw(statuswin, 5, 0, " Block: %s... Diff:%s Started: %s Best share: %s ",
current_hash, block_diff, blocktime, best_share);
mvwhline(statuswin, 6, 0, '-', 80);
mvwhline(statuswin, statusy - 1, 0, '-', 80);
- mvwprintw(statuswin, devcursor - 1, 1, "[P]ool management %s[S]ettings [D]isplay options [Q]uit",
+ cg_mvwprintw(statuswin, devcursor - 1, 1, "[P]ool management %s[S]ettings [D]isplay options [Q]uit",
have_opencl ? "[G]PU management " : "");
}
@@ -2134,10 +2146,10 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count)
wu = cgpu->diff1 / dev_runtime * 60;
wmove(statuswin,devcursor + count, 0);
- wprintw(statuswin, " %s %*d: ", cgpu->drv->name, dev_width, cgpu->device_id);
+ cg_wprintw(statuswin, " %s %*d: ", cgpu->drv->name, dev_width, cgpu->device_id);
logline[0] = '\0';
cgpu->drv->get_statline_before(logline, sizeof(logline), cgpu);
- wprintw(statuswin, "%s", logline);
+ cg_wprintw(statuswin, "%s", logline);
dh64 = (double)cgpu->total_mhashes / dev_runtime * 1000000ull;
dr64 = (double)cgpu->rolling * 1000000ull;
@@ -2146,25 +2158,25 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count)
#ifdef USE_USBUTILS
if (cgpu->usbinfo.nodev)
- wprintw(statuswin, "ZOMBIE");
+ cg_wprintw(statuswin, "ZOMBIE");
else
#endif
if (cgpu->status == LIFE_DEAD)
- wprintw(statuswin, "DEAD ");
+ cg_wprintw(statuswin, "DEAD ");
else if (cgpu->status == LIFE_SICK)
- wprintw(statuswin, "SICK ");
+ cg_wprintw(statuswin, "SICK ");
else if (cgpu->deven == DEV_DISABLED)
- wprintw(statuswin, "OFF ");
+ cg_wprintw(statuswin, "OFF ");
else if (cgpu->deven == DEV_RECOVER)
- wprintw(statuswin, "REST ");
+ cg_wprintw(statuswin, "REST ");
else
- wprintw(statuswin, "%6s", displayed_rolling);
+ cg_wprintw(statuswin, "%6s", displayed_rolling);
adj_fwidth(cgpu->diff_accepted, &dawidth);
adj_fwidth(cgpu->diff_rejected, &drwidth);
adj_width(cgpu->hw_errors, &hwwidth);
adj_width(wu, &wuwidth);
- wprintw(statuswin, "/%6sh/s | A:%*.0f R:%*.0f HW:%*d WU:%*.1f/m",
+ cg_wprintw(statuswin, "/%6sh/s | A:%*.0f R:%*.0f HW:%*d WU:%*.1f/m",
displayed_hashes,
dawidth, cgpu->diff_accepted,
drwidth, cgpu->diff_rejected,
@@ -2173,7 +2185,7 @@ static void curses_print_devstatus(struct cgpu_info *cgpu, int count)
logline[0] = '\0';
cgpu->drv->get_statline(logline, sizeof(logline), cgpu);
- wprintw(statuswin, "%s", logline);
+ cg_wprintw(statuswin, "%s", logline);
wclrtoeol(statuswin);
}