summaryrefslogtreecommitdiffstats
path: root/src/H5timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5timer.c')
-rw-r--r--src/H5timer.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/H5timer.c b/src/H5timer.c
index b5dba97..83fd243 100644
--- a/src/H5timer.c
+++ b/src/H5timer.c
@@ -96,7 +96,7 @@
*-------------------------------------------------------------------------
*/
void
-H5_bandwidth(char *buf /*out*/, double nbytes, double nseconds)
+H5_bandwidth(char *buf /*out*/, size_t bufsize, double nbytes, double nseconds)
{
double bw;
@@ -107,35 +107,35 @@ H5_bandwidth(char *buf /*out*/, double nbytes, double nseconds)
if (H5_DBL_ABS_EQUAL(bw, 0.0))
HDstrcpy(buf, "0.000 B/s");
else if (bw < 1.0)
- HDsprintf(buf, "%10.4e", bw);
+ HDsnprintf(buf, bufsize, "%10.4e", bw);
else if (bw < (double)H5_KB) {
- HDsprintf(buf, "%05.4f", bw);
+ HDsnprintf(buf, bufsize, "%05.4f", bw);
HDstrcpy(buf + 5, " B/s");
}
else if (bw < (double)H5_MB) {
- HDsprintf(buf, "%05.4f", bw / (double)H5_KB);
+ HDsnprintf(buf, bufsize, "%05.4f", bw / (double)H5_KB);
HDstrcpy(buf + 5, " kB/s");
}
else if (bw < (double)H5_GB) {
- HDsprintf(buf, "%05.4f", bw / (double)H5_MB);
+ HDsnprintf(buf, bufsize, "%05.4f", bw / (double)H5_MB);
HDstrcpy(buf + 5, " MB/s");
}
else if (bw < (double)H5_TB) {
- HDsprintf(buf, "%05.4f", bw / (double)H5_GB);
+ HDsnprintf(buf, bufsize, "%05.4f", bw / (double)H5_GB);
HDstrcpy(buf + 5, " GB/s");
}
else if (bw < (double)H5_PB) {
- HDsprintf(buf, "%05.4f", bw / (double)H5_TB);
+ HDsnprintf(buf, bufsize, "%05.4f", bw / (double)H5_TB);
HDstrcpy(buf + 5, " TB/s");
}
else if (bw < (double)H5_EB) {
- HDsprintf(buf, "%05.4f", bw / (double)H5_PB);
+ HDsnprintf(buf, bufsize, "%05.4f", bw / (double)H5_PB);
HDstrcpy(buf + 5, " PB/s");
}
else {
- HDsprintf(buf, "%10.4e", bw);
+ HDsnprintf(buf, bufsize, "%10.4e", bw);
if (HDstrlen(buf) > 10)
- HDsprintf(buf, "%10.3e", bw);
+ HDsnprintf(buf, bufsize, "%10.3e", bw);
} /* end else-if */
} /* end else */
} /* end H5_bandwidth() */
@@ -627,30 +627,31 @@ H5_timer_get_time_string(double seconds)
* (name? round_up_size? ?)
*/
if (seconds < 0.0)
- HDsprintf(s, "N/A");
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "N/A");
else if (H5_DBL_ABS_EQUAL(0.0, seconds))
- HDsprintf(s, "0.0 s");
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "0.0 s");
else if (seconds < 1.0E-6)
/* t < 1 us, Print time in ns */
- HDsprintf(s, "%.f ns", seconds * 1.0E9);
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "%.f ns", seconds * 1.0E9);
else if (seconds < 1.0E-3)
/* t < 1 ms, Print time in us */
- HDsprintf(s, "%.1f us", seconds * 1.0E6);
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "%.1f us", seconds * 1.0E6);
else if (seconds < 1.0)
/* t < 1 s, Print time in ms */
- HDsprintf(s, "%.1f ms", seconds * 1.0E3);
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "%.1f ms", seconds * 1.0E3);
else if (seconds < H5_SEC_PER_MIN)
/* t < 1 m, Print time in s */
- HDsprintf(s, "%.2f s", seconds);
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "%.2f s", seconds);
else if (seconds < H5_SEC_PER_HOUR)
/* t < 1 h, Print time in m and s */
- HDsprintf(s, "%.f m %.f s", minutes, remainder_sec);
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "%.f m %.f s", minutes, remainder_sec);
else if (seconds < H5_SEC_PER_DAY)
/* t < 1 d, Print time in h, m and s */
- HDsprintf(s, "%.f h %.f m %.f s", hours, minutes, remainder_sec);
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "%.f h %.f m %.f s", hours, minutes, remainder_sec);
else
/* Print time in d, h, m and s */
- HDsprintf(s, "%.f d %.f h %.f m %.f s", days, hours, minutes, remainder_sec);
+ HDsnprintf(s, H5TIMER_TIME_STRING_LEN, "%.f d %.f h %.f m %.f s", days, hours, minutes,
+ remainder_sec);
return s;
} /* end H5_timer_get_time_string() */