Ensure we have enough room for the ETA runstr
The calculation of 1:4 is wrong, it's 1:5. And we missed the similar
change in server.c.
Reported-by: Andreas Grünbacher <andreas.gruenbacher@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/eta.c b/eta.c
index 0dd04be..dfe66f9 100644
--- a/eta.c
+++ b/eta.c
@@ -10,9 +10,9 @@
static char __run_str[REAL_MAX_JOBS + 1];
/*
- * Worst level condensing would be 1:4, so allow enough room for that
+ * Worst level condensing would be 1:5, so allow enough room for that
*/
-static char run_str[(4 * REAL_MAX_JOBS) + 1];
+static char run_str[__THREAD_RUNSTR_SZ(REAL_MAX_JOBS)];
static void update_condensed_str(char *run_str, char *run_str_condensed)
{
@@ -592,7 +592,7 @@
if (!thread_number)
return;
- size = sizeof(*je) + thread_number * sizeof(char) + 1;
+ size = sizeof(*je) + THREAD_RUNSTR_SZ;
je = malloc(size);
memset(je, 0, size);
diff --git a/server.c b/server.c
index 8865502..e20f592 100644
--- a/server.c
+++ b/server.c
@@ -673,7 +673,7 @@
if (!thread_number)
return 0;
- size = sizeof(*je) + thread_number * sizeof(char) + 1;
+ size = sizeof(*je) + THREAD_RUNSTR_SZ;
je = malloc(size);
memset(je, 0, size);
diff --git a/stat.h b/stat.h
index 3f68305..2c2f1e1 100644
--- a/stat.h
+++ b/stat.h
@@ -241,4 +241,7 @@
return 1;
}
+#define __THREAD_RUNSTR_SZ(nr) (((nr) * 5) + 1)
+#define THREAD_RUNSTR_SZ __THREAD_RUNSTR_SZ(thread_number)
+
#endif