Commit 13a382ad516b896121b594bc3694d50d4e34813e

kanoi 2014-02-27T13:57:47

Merge pull request #555 from kanoi/master api - buffer size off by 1 for joined commands + minion statline cleanup

diff --git a/api.c b/api.c
index a4234eb..e3dc72d 100644
--- a/api.c
+++ b/api.c
@@ -4690,8 +4690,8 @@ void api(int api_thr_id)
 				if (!did) {
 					if (strchr(cmd, CMDJOIN)) {
 						firstjoin = isjoin = true;
-						// cmd + leading '|' + '\0'
-						cmdsbuf = malloc(strlen(cmd) + 2);
+						// cmd + leading+tailing '|' + '\0'
+						cmdsbuf = malloc(strlen(cmd) + 3);
 						if (!cmdsbuf)
 							quithere(1, "OOM cmdsbuf");
 						strcpy(cmdsbuf, "|");
diff --git a/driver-minion.c b/driver-minion.c
index 6bbc9f8..4c12f8c 100644
--- a/driver-minion.c
+++ b/driver-minion.c
@@ -2569,33 +2569,22 @@ static void minion_get_statline_before(char *buf, size_t bufsiz, struct cgpu_inf
 {
 	struct minion_info *minioninfo = (struct minion_info *)(minioncgpu->device_data);
 	uint16_t max_temp, cores;
-	int chip, sp;
+	int chip;
 
 	max_temp = 0;
 	cores = 0;
 	mutex_lock(&(minioninfo->sta_lock));
-		for (chip = 0; chip < MINION_CHIPS; chip++) {
-			if (minioninfo->chip[chip]) {
-				cores += minioninfo->chip_status[chip].cores;
-				if (max_temp < minioninfo->chip_status[chip].temp)
-					max_temp = minioninfo->chip_status[chip].temp;
-			}
+	for (chip = 0; chip < MINION_CHIPS; chip++) {
+		if (minioninfo->chip[chip]) {
+			cores += minioninfo->chip_status[chip].cores;
+			if (max_temp < minioninfo->chip_status[chip].temp)
+				max_temp = minioninfo->chip_status[chip].temp;
 		}
-	mutex_unlock(&(minioninfo->sta_lock));
-
-	sp = 0;
-	if (cores < 100) {
-		sp++;
-		if (cores < 10)
-			sp++;
 	}
+	mutex_unlock(&(minioninfo->sta_lock));
 
-	// Space limited - 99 means 99 or more
-	if (max_temp > 99)
-		max_temp = 99;
-
-	tailsprintf(buf, bufsiz, "max%2dC Ch:%2d.%d%*s", (int)max_temp,
-				 minioninfo->chips, (int)cores, sp, "");
+	tailsprintf(buf, bufsiz, "max%3dC Ch:%2d Co:%d",
+				 (int)max_temp, minioninfo->chips, (int)cores);
 }
 
 #define CHIPS_PER_STAT 8