diff options
author | Bart Van Assche <bvanassche@acm.org> | 2020-07-02 14:56:16 -0700 |
---|---|---|
committer | Bart Van Assche <bvanassche@acm.org> | 2020-07-02 15:27:26 -0700 |
commit | 832a318683374475b4125cfdd5262c9c8cccb22a (patch) | |
tree | cbcd7f5a82ebc31ced59dcd309e531dd24317a12 /lib | |
parent | 38b00241e3bd97b1aed6b669b357f2ec89743f0c (diff) | |
download | fio-832a318683374475b4125cfdd5262c9c8cccb22a.tar.gz fio-832a318683374475b4125cfdd5262c9c8cccb22a.tar.bz2 |
num2str(): Remove the fmt[] array
This patch does not change any functionality.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/num2str.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/num2str.c b/lib/num2str.c index ce177275..923e21d9 100644 --- a/lib/num2str.c +++ b/lib/num2str.c @@ -34,7 +34,7 @@ char *num2str(uint64_t num, int maxlen, int base, int pow2, enum n2s_unit units) const unsigned int thousand = pow2 ? 1024 : 1000; unsigned int modulo; int post_index, carry = 0; - char tmp[32], fmt[32]; + char tmp[32]; char *buf; compiletime_assert(sizeof(sistr) == sizeof(iecstr), "unit prefix arrays must be identical sizes"); @@ -109,8 +109,8 @@ done: */ assert(maxlen - strlen(tmp) - 1 > 0); assert(modulo < thousand); - sprintf(fmt, "%%.%df", (int)(maxlen - strlen(tmp) - 1)); - sprintf(tmp, fmt, (double)modulo / (double)thousand); + sprintf(tmp, "%.*f", (int)(maxlen - strlen(tmp) - 1), + (double)modulo / (double)thousand); if (asprintf(&buf, "%llu.%s%s%s", (unsigned long long) num, &tmp[2], unitprefix[post_index], unitstr[units]) < 0) |