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).
This commit is contained in:
parent
283ec9df45
commit
3af7c80523
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user