mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-10 23:08:07 +00:00
size check get_datestamp/get_timestamp and remove unused cgpu->init
This commit is contained in:
parent
385a70bea7
commit
ad1572f77f
12
cgminer.c
12
cgminer.c
@ -358,13 +358,13 @@ static bool should_run(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void get_datestamp(char *f, struct timeval *tv)
|
||||
void get_datestamp(char *f, size_t fsiz, struct timeval *tv)
|
||||
{
|
||||
struct tm *tm;
|
||||
|
||||
const time_t tmp_time = tv->tv_sec;
|
||||
tm = localtime(&tmp_time);
|
||||
sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d]",
|
||||
snprintf(f, fsiz, "[%d-%02d-%02d %02d:%02d:%02d]",
|
||||
tm->tm_year + 1900,
|
||||
tm->tm_mon + 1,
|
||||
tm->tm_mday,
|
||||
@ -373,13 +373,13 @@ void get_datestamp(char *f, struct timeval *tv)
|
||||
tm->tm_sec);
|
||||
}
|
||||
|
||||
void get_timestamp(char *f, struct timeval *tv)
|
||||
static void get_timestamp(char *f, size_t fsiz, struct timeval *tv)
|
||||
{
|
||||
struct tm *tm;
|
||||
|
||||
const time_t tmp_time = tv->tv_sec;
|
||||
tm = localtime(&tmp_time);
|
||||
sprintf(f, "[%02d:%02d:%02d]",
|
||||
snprintf(f, fsiz, "[%02d:%02d:%02d]",
|
||||
tm->tm_hour,
|
||||
tm->tm_min,
|
||||
tm->tm_sec);
|
||||
@ -3597,7 +3597,7 @@ static void set_curblock(char *hexstr, unsigned char *hash)
|
||||
current_hash = bin2hex(hash_swap + 2, 8);
|
||||
free(current_fullhash);
|
||||
current_fullhash = bin2hex(block_hash_swap, 32);
|
||||
get_timestamp(blocktime, &block_timeval);
|
||||
get_timestamp(blocktime, sizeof(blocktime), &block_timeval);
|
||||
cg_wunlock(&ch_lock);
|
||||
|
||||
applog(LOG_INFO, "New block: %s... diff %s", current_hash, block_diff);
|
||||
@ -7717,7 +7717,7 @@ begin_bench:
|
||||
|
||||
cgtime(&total_tv_start);
|
||||
cgtime(&total_tv_end);
|
||||
get_datestamp(datestamp, &total_tv_start);
|
||||
get_datestamp(datestamp, sizeof(datestamp), &total_tv_start);
|
||||
|
||||
// Start threads
|
||||
k = 0;
|
||||
|
@ -985,7 +985,6 @@ static bool avalon_prepare(struct thr_info *thr)
|
||||
{
|
||||
struct cgpu_info *avalon = thr->cgpu;
|
||||
struct avalon_info *info = avalon->device_data;
|
||||
struct timeval now;
|
||||
|
||||
free(avalon->works);
|
||||
avalon->works = calloc(info->miner_count * sizeof(struct work *),
|
||||
@ -1008,8 +1007,6 @@ static bool avalon_prepare(struct thr_info *thr)
|
||||
|
||||
avalon_init(avalon);
|
||||
|
||||
cgtime(&now);
|
||||
get_datestamp(avalon->init, &now);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1781,7 +1781,6 @@ static bool bflsc_thread_prepare(struct thr_info *thr)
|
||||
{
|
||||
struct cgpu_info *bflsc = thr->cgpu;
|
||||
struct bflsc_info *sc_info = (struct bflsc_info *)(bflsc->device_data);
|
||||
struct timeval now;
|
||||
|
||||
if (thr_info_create(&(sc_info->results_thr), NULL, bflsc_get_results, (void *)bflsc)) {
|
||||
applog(LOG_ERR, "%s%i: thread create failed", bflsc->drv->name, bflsc->device_id);
|
||||
@ -1789,9 +1788,6 @@ static bool bflsc_thread_prepare(struct thr_info *thr)
|
||||
}
|
||||
pthread_detach(sc_info->results_thr.pth);
|
||||
|
||||
cgtime(&now);
|
||||
get_datestamp(bflsc->init, &now);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -306,13 +306,9 @@ static void get_bitforce_statline_before(char *buf, size_t bufsiz, struct cgpu_i
|
||||
tailsprintf(buf, bufsiz, " | ");
|
||||
}
|
||||
|
||||
static bool bitforce_thread_prepare(struct thr_info *thr)
|
||||
static bool bitforce_thread_prepare(__maybe_unused struct thr_info *thr)
|
||||
{
|
||||
struct cgpu_info *bitforce = thr->cgpu;
|
||||
struct timeval now;
|
||||
|
||||
cgtime(&now);
|
||||
get_datestamp(bitforce->init, &now);
|
||||
// struct cgpu_info *bitforce = thr->cgpu;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -839,14 +839,9 @@ static void icarus_detect()
|
||||
usb_detect(&icarus_drv, icarus_detect_one);
|
||||
}
|
||||
|
||||
static bool icarus_prepare(struct thr_info *thr)
|
||||
static bool icarus_prepare(__maybe_unused struct thr_info *thr)
|
||||
{
|
||||
struct cgpu_info *icarus = thr->cgpu;
|
||||
|
||||
struct timeval now;
|
||||
|
||||
cgtime(&now);
|
||||
get_datestamp(icarus->init, &now);
|
||||
// struct cgpu_info *icarus = thr->cgpu;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -569,13 +569,9 @@ dame:
|
||||
|
||||
static bool modminer_fpga_prepare(struct thr_info *thr)
|
||||
{
|
||||
struct cgpu_info *modminer = thr->cgpu;
|
||||
struct timeval now;
|
||||
|
||||
cgtime(&now);
|
||||
get_datestamp(modminer->init, &now);
|
||||
|
||||
// struct cgpu_info *modminer = thr->cgpu;
|
||||
struct modminer_fpga_state *state;
|
||||
|
||||
state = thr->cgpu_data = calloc(1, sizeof(struct modminer_fpga_state));
|
||||
state->shares_to_good = MODMINER_EARLY_UP;
|
||||
state->overheated = false;
|
||||
|
@ -698,7 +698,7 @@ retry:
|
||||
thr = get_thread(i);
|
||||
if (thr->cgpu != cgpu)
|
||||
continue;
|
||||
get_datestamp(checkin, &thr->last);
|
||||
get_datestamp(checkin, sizeof(checkin), &thr->last);
|
||||
displayed_rolling = thr->rolling;
|
||||
if (!mhash_base)
|
||||
displayed_rolling *= 1000;
|
||||
@ -1197,7 +1197,7 @@ select_cgpu:
|
||||
}
|
||||
|
||||
cgtime(&now);
|
||||
get_datestamp(cgpu->init, &now);
|
||||
get_datestamp(cgpu->init, sizeof(cgpu->init), &now);
|
||||
|
||||
for (thr_id = 0; thr_id < mining_threads; ++thr_id) {
|
||||
thr = get_thread(thr_id);
|
||||
@ -1382,7 +1382,7 @@ static bool opencl_thread_prepare(struct thr_info *thr)
|
||||
}
|
||||
applog(LOG_INFO, "initCl() finished. Found %s", name);
|
||||
cgtime(&now);
|
||||
get_datestamp(cgpu->init, &now);
|
||||
get_datestamp(cgpu->init, sizeof(cgpu->init), &now);
|
||||
|
||||
have_opencl = true;
|
||||
|
||||
|
@ -372,13 +372,9 @@ static void ztex_statline_before(char *buf, size_t bufsiz, struct cgpu_info *cgp
|
||||
|
||||
static bool ztex_prepare(struct thr_info *thr)
|
||||
{
|
||||
struct timeval now;
|
||||
struct cgpu_info *cgpu = thr->cgpu;
|
||||
struct libztex_device *ztex = cgpu->device_ztex;
|
||||
|
||||
cgtime(&now);
|
||||
get_datestamp(cgpu->init, &now);
|
||||
|
||||
ztex_selectFpga(ztex);
|
||||
if (libztex_configureFpga(ztex) != 0) {
|
||||
libztex_resetFpga(ztex);
|
||||
|
2
miner.h
2
miner.h
@ -1284,7 +1284,7 @@ struct modminer_fpga_state {
|
||||
strcat(buf, tmp13); \
|
||||
} while (0)
|
||||
|
||||
extern void get_datestamp(char *, struct timeval *);
|
||||
extern void get_datestamp(char *, size_t, struct timeval *);
|
||||
extern void inc_hw_errors(struct thr_info *thr);
|
||||
extern bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
|
||||
extern struct work *get_queued(struct cgpu_info *cgpu);
|
||||
|
Loading…
Reference in New Issue
Block a user