Merge pull request #555 from kanoi/master api - buffer size off by 1 for joined commands + minion statline cleanup
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
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