diff options
author | pfg <pfg@FreeBSD.org> | 2017-04-21 20:03:08 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2017-04-21 20:03:08 +0000 |
commit | f4b48fe541e1df99ec980e982b9e0ebf7932ea8c (patch) | |
tree | eff9b2e7e03e1c7b174e32f22d5ba36a66cd863e /usr.bin/mkimg | |
parent | 67a167184e570c9dcad4228c69da5889fa01420a (diff) | |
download | FreeBSD-src-f4b48fe541e1df99ec980e982b9e0ebf7932ea8c.zip FreeBSD-src-f4b48fe541e1df99ec980e982b9e0ebf7932ea8c.tar.gz |
MFC r302664:
mkimg(1): minor cleanups with argument order in calloc(3).
Generally the first argument in calloc is supposed to stand for a count
and the second for a size. Try to make that consistent. While here,
attempt to make some use of the overflow detection capability in
calloc(3).
Requested by: manu
Diffstat (limited to 'usr.bin/mkimg')
-rw-r--r-- | usr.bin/mkimg/vmdk.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/mkimg/vmdk.c b/usr.bin/mkimg/vmdk.c index a07d0b8..743418b 100644 --- a/usr.bin/mkimg/vmdk.c +++ b/usr.bin/mkimg/vmdk.c @@ -149,7 +149,7 @@ vmdk_write(int fd) gdsz = (ngts * sizeof(uint32_t) + VMDK_SECTOR_SIZE - 1) & ~(VMDK_SECTOR_SIZE - 1); - gd = calloc(gdsz, 1); + gd = calloc(1, gdsz); if (gd == NULL) { free(desc); return (ENOMEM); @@ -161,7 +161,7 @@ vmdk_write(int fd) sec += VMDK_NGTES * sizeof(uint32_t) / VMDK_SECTOR_SIZE; } - rgd = calloc(gdsz, 1); + rgd = calloc(1, gdsz); if (rgd == NULL) { free(gd); free(desc); @@ -183,14 +183,14 @@ vmdk_write(int fd) le64enc(&hdr.overhead, sec); be32enc(&hdr.nl_test, VMDK_NL_TEST); - gtsz = ngts * VMDK_NGTES * sizeof(uint32_t); - gt = calloc(gtsz, 1); + gt = calloc(ngts, VMDK_NGTES * sizeof(uint32_t)); if (gt == NULL) { free(rgd); free(gd); free(desc); return (ENOMEM); } + gtsz = ngts * VMDK_NGTES * sizeof(uint32_t); cursec = sec; blkcnt = (grainsz * VMDK_SECTOR_SIZE) / secsz; @@ -225,7 +225,7 @@ vmdk_write(int fd) cur = VMDK_SECTOR_SIZE + desc_len + (gdsz + gtsz) * 2; lim = sec * VMDK_SECTOR_SIZE; if (cur < lim) { - buf = calloc(VMDK_SECTOR_SIZE, 1); + buf = calloc(1, VMDK_SECTOR_SIZE); if (buf == NULL) error = ENOMEM; while (!error && cur < lim) { |