From: Shachar Sharon Date: Tue, 19 Aug 2025 09:18:28 +0000 (+0300) Subject: tdbtorture: Fix CID 1034816: proper calloc usage X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=affb734a2568a342e443872ae6c789ef03f5faa6;p=thirdparty%2Fsamba.git tdbtorture: Fix CID 1034816: proper calloc usage Standard signature is 'calloc(n_elems, elem_size)', where element size (in particular, when using 'sizeof') comes as 2nd arg. The actual allocation size does not care for ordering but swapping the order confuses static-analysis tools like Coverity, as well as naive readers. Signed-off-by: Shachar Sharon Reviewed-by: Vinit Agnihotri Reviewed-by: Shweta Sodani Reviewed-by: Rabinarayan Panigrahi Reviewed-by: Anoop C S Reviewed-by: Guenther Deschner Reviewed-by: Volker Lendecke Autobuild-User(master): Günther Deschner Autobuild-Date(master): Tue Aug 19 18:08:02 UTC 2025 on atb-devel-224 --- diff --git a/lib/tdb/tools/tdbtorture.c b/lib/tdb/tools/tdbtorture.c index 1063f14f4cc..14dc5e7a8d1 100644 --- a/lib/tdb/tools/tdbtorture.c +++ b/lib/tdb/tools/tdbtorture.c @@ -374,12 +374,12 @@ int main(int argc, char * const *argv) goto done; } - pids = (pid_t *)calloc(sizeof(pid_t), num_procs); + pids = (pid_t *)calloc(num_procs, sizeof(pid_t)); if (pids == NULL) { perror("Unable to allocate memory for pids"); exit(1); } - done = (int *)calloc(sizeof(int), num_procs); + done = (int *)calloc(num_procs, sizeof(int)); if (done == NULL) { perror("Unable to allocate memory for done"); exit(1);