Browse Source

Merge commit 'ad1572f' into cg_merges_20130818a

Conflicts:
	driver-avalon.c
	driver-bflsc.c
	driver-bitforce.c
	driver-icarus.c
	driver-modminer.c
	driver-opencl.c
	driver-ztex.c
	miner.c
	miner.h
Luke Dashjr 12 years ago
parent
commit
17eb22dfea
9 changed files with 14 additions and 20 deletions
  1. 0 1
      driver-avalon.c
  2. 0 1
      driver-bitforce.c
  3. 0 1
      driver-icarus.c
  4. 0 2
      driver-modminer.c
  5. 3 3
      driver-opencl.c
  6. 0 2
      driver-ztex.c
  7. 2 2
      logging.c
  8. 7 6
      miner.c
  9. 2 2
      miner.h

+ 0 - 1
driver-avalon.c

@@ -673,7 +673,6 @@ static bool avalon_prepare(struct thr_info *thr)
 	else
 	else
 		__avalon_init(avalon);
 		__avalon_init(avalon);
 
 
-	get_now_datestamp(avalon->init);
 	avalon->status = LIFE_INIT2;
 	avalon->status = LIFE_INIT2;
 	return true;
 	return true;
 }
 }

+ 0 - 1
driver-bitforce.c

@@ -370,7 +370,6 @@ static bool bitforce_thread_prepare(struct thr_info *thr)
 	bitforce->device_fd = fdDev;
 	bitforce->device_fd = fdDev;
 
 
 	applog(LOG_INFO, "%s: Opened %s", bitforce->dev_repr, bitforce->device_path);
 	applog(LOG_INFO, "%s: Opened %s", bitforce->dev_repr, bitforce->device_path);
-	get_now_datestamp(bitforce->init);
 
 
 	return true;
 	return true;
 }
 }

+ 0 - 1
driver-icarus.c

@@ -657,7 +657,6 @@ static bool icarus_prepare(struct thr_info *thr)
 	icarus->device_fd = fd;
 	icarus->device_fd = fd;
 
 
 	applog(LOG_INFO, "Opened Icarus on %s", icarus->device_path);
 	applog(LOG_INFO, "Opened Icarus on %s", icarus->device_path);
-	get_now_datestamp(icarus->init);
 
 
 	struct icarus_state *state;
 	struct icarus_state *state;
 	thr->cgpu_data = state = calloc(1, sizeof(*state));
 	thr->cgpu_data = state = calloc(1, sizeof(*state));

+ 0 - 2
driver-modminer.c

@@ -276,8 +276,6 @@ modminer_device_prepare(struct cgpu_info *modminer)
 	modminer->device->device_fd = fd;
 	modminer->device->device_fd = fd;
 	applog(LOG_INFO, "%s: Opened %s", modminer->dev_repr, modminer->device_path);
 	applog(LOG_INFO, "%s: Opened %s", modminer->dev_repr, modminer->device_path);
 
 
-	get_now_datestamp(modminer->init);
-
 	return true;
 	return true;
 }
 }
 
 

+ 3 - 3
driver-opencl.c

@@ -890,7 +890,7 @@ void opencl_wlogprint_status(struct cgpu_info *cgpu)
 		if (thr->cgpu != cgpu)
 		if (thr->cgpu != cgpu)
 			continue;
 			continue;
 		
 		
-		get_datestamp(checkin, time(NULL) - timer_elapsed(&thr->last, NULL));
+		get_datestamp(checkin, sizeof(checkin), time(NULL) - timer_elapsed(&thr->last, NULL));
 		displayed_rolling = thr->rolling;
 		displayed_rolling = thr->rolling;
 		if (!mhash_base)
 		if (!mhash_base)
 			displayed_rolling *= 1000;
 			displayed_rolling *= 1000;
@@ -1318,7 +1318,7 @@ select_cgpu:
 		applog(LOG_WARNING, "Thread %d restarted", thr_id);
 		applog(LOG_WARNING, "Thread %d restarted", thr_id);
 	}
 	}
 
 
-	get_now_datestamp(sel_cgpu->init);
+	get_now_datestamp(sel_cgpu->init, sizeof(sel_cgpu->init));
 
 
 	proc_enable(cgpu);
 	proc_enable(cgpu);
 
 
@@ -1570,7 +1570,7 @@ static bool opencl_thread_prepare(struct thr_info *thr)
 		}
 		}
 	}
 	}
 	applog(LOG_INFO, "initCl() finished. Found %s", name);
 	applog(LOG_INFO, "initCl() finished. Found %s", name);
-	get_now_datestamp(cgpu->init);
+	get_now_datestamp(cgpu->init, sizeof(cgpu->init));
 
 
 	have_opencl = true;
 	have_opencl = true;
 
 

+ 0 - 2
driver-ztex.c

@@ -342,8 +342,6 @@ static bool ztex_prepare(struct thr_info *thr)
 	struct cgpu_info *cgpu = thr->cgpu;
 	struct cgpu_info *cgpu = thr->cgpu;
 	struct libztex_device *ztex = cgpu->device_ztex;
 	struct libztex_device *ztex = cgpu->device_ztex;
 
 
-	get_now_datestamp(cgpu->init);
-	
 	{
 	{
 		char *fpganame = malloc(LIBZTEX_SNSTRING_LEN+3+1);
 		char *fpganame = malloc(LIBZTEX_SNSTRING_LEN+3+1);
 		sprintf(fpganame, "%s-%u", ztex->snString, cgpu->proc_id+1);
 		sprintf(fpganame, "%s-%u", ztex->snString, cgpu->proc_id+1);

+ 2 - 2
logging.c

@@ -69,7 +69,7 @@ void _applog(int prio, const char *str)
 			bfg_gettimeofday(&tv);
 			bfg_gettimeofday(&tv);
 			localtime_r(&tv.tv_sec, &tm);
 			localtime_r(&tv.tv_sec, &tm);
 			
 			
-			sprintf(datetime, "[%d-%02d-%02d %02d:%02d:%02d.%06ld]",
+			snprintf(datetime, sizeof(datetime), "[%d-%02d-%02d %02d:%02d:%02d.%06ld]",
 				tm.tm_year + 1900,
 				tm.tm_year + 1900,
 				tm.tm_mon + 1,
 				tm.tm_mon + 1,
 				tm.tm_mday,
 				tm.tm_mday,
@@ -79,7 +79,7 @@ void _applog(int prio, const char *str)
 				(long)tv.tv_usec);
 				(long)tv.tv_usec);
 		}
 		}
 		else
 		else
-			get_now_datestamp(datetime);
+			get_now_datestamp(datetime, sizeof(datetime));
 
 
 		if (writetofile || writetocon)
 		if (writetofile || writetocon)
 		{
 		{

+ 7 - 6
miner.c

@@ -421,7 +421,7 @@ static bool should_run(void)
 	return within_range;
 	return within_range;
 }
 }
 
 
-void get_datestamp(char *f, time_t tt)
+void get_datestamp(char *f, size_t fsiz, time_t tt)
 {
 {
 	struct tm _tm;
 	struct tm _tm;
 	struct tm *tm = &_tm;
 	struct tm *tm = &_tm;
@@ -430,7 +430,7 @@ void get_datestamp(char *f, time_t tt)
 		tt = time(NULL);
 		tt = time(NULL);
 
 
 	localtime_r(&tt, tm);
 	localtime_r(&tt, tm);
-	sprintf(f, "[%d-%02d-%02d %02d:%02d:%02d]",
+	snprintf(f, fsiz, "[%d-%02d-%02d %02d:%02d:%02d]",
 		tm->tm_year + 1900,
 		tm->tm_year + 1900,
 		tm->tm_mon + 1,
 		tm->tm_mon + 1,
 		tm->tm_mday,
 		tm->tm_mday,
@@ -439,13 +439,14 @@ void get_datestamp(char *f, time_t tt)
 		tm->tm_sec);
 		tm->tm_sec);
 }
 }
 
 
-void get_timestamp(char *f, time_t tt)
+static
+void get_timestamp(char *f, size_t fsiz, time_t tt)
 {
 {
 	struct tm _tm;
 	struct tm _tm;
 	struct tm *tm = &_tm;
 	struct tm *tm = &_tm;
 
 
 	localtime_r(&tt, tm);
 	localtime_r(&tt, tm);
-	sprintf(f, "[%02d:%02d:%02d]",
+	snprintf(f, fsiz, "[%02d:%02d:%02d]",
 		tm->tm_hour,
 		tm->tm_hour,
 		tm->tm_min,
 		tm->tm_min,
 		tm->tm_sec);
 		tm->tm_sec);
@@ -5201,7 +5202,7 @@ static void set_curblock(char *hexstr, unsigned char *hash)
 	free(current_fullhash);
 	free(current_fullhash);
 	current_fullhash = malloc(65);
 	current_fullhash = malloc(65);
 	bin2hex(current_fullhash, hash_swap, 32);
 	bin2hex(current_fullhash, hash_swap, 32);
-	get_timestamp(blocktime, block_time);
+	get_timestamp(blocktime, sizeof(blocktime), block_time);
 	cg_wunlock(&ch_lock);
 	cg_wunlock(&ch_lock);
 
 
 	applog(LOG_INFO, "New block: %s diff %s (%s)", current_hash, block_diff, net_hashrate);
 	applog(LOG_INFO, "New block: %s diff %s (%s)", current_hash, block_diff, net_hashrate);
@@ -10016,7 +10017,7 @@ begin_bench:
 		localtime_r(&miner_start_ts, &schedstart.tm);
 		localtime_r(&miner_start_ts, &schedstart.tm);
 	if (schedstop.tm.tm_sec)
 	if (schedstop.tm.tm_sec)
 		localtime_r(&miner_start_ts, &schedstop .tm);
 		localtime_r(&miner_start_ts, &schedstop .tm);
-	get_datestamp(datestamp, miner_start_ts);
+	get_datestamp(datestamp, sizeof(datestamp), miner_start_ts);
 
 
 	// Initialise processors and threads
 	// Initialise processors and threads
 	k = 0;
 	k = 0;

+ 2 - 2
miner.h

@@ -1280,8 +1280,8 @@ struct work {
 	struct work *next;
 	struct work *next;
 };
 };
 
 
-extern void get_datestamp(char *, time_t);
-#define get_now_datestamp(buf)  get_datestamp(buf, INVALID_TIMESTAMP)
+extern void get_datestamp(char *, size_t, time_t);
+#define get_now_datestamp(buf, bufsz)  get_datestamp(buf, bufsz, INVALID_TIMESTAMP)
 extern void inc_hw_errors2(struct thr_info *thr, const struct work *work, const uint32_t *bad_nonce_p);
 extern void inc_hw_errors2(struct thr_info *thr, const struct work *work, const uint32_t *bad_nonce_p);
 extern void inc_hw_errors(struct thr_info *, const struct work *, const uint32_t bad_nonce);
 extern void inc_hw_errors(struct thr_info *, const struct work *, const uint32_t bad_nonce);
 #define inc_hw_errors_only(thr)  inc_hw_errors(thr, NULL, 0)
 #define inc_hw_errors_only(thr)  inc_hw_errors(thr, NULL, 0)