Skip to content

Commit

Permalink
example/cmtime: Correct argument order in calloc call to fix warning
Browse files Browse the repository at this point in the history
This commit fixes a compiler warning related to the use of calloc.
```
librdmacm/examples/cmtime.c:993:31: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  993 |         nodes = calloc(sizeof *nodes, iter);
      |                               ^
librdmacm/examples/cmtime.c:993:31: note: earlier argument should specify number of elements, later size of each element

```

The warning was due to transposed arguments in the calloc call,
where the number of elements and the size of each element were
specified in the wrong order.

The correct order for calloc's arguments is:
void *calloc(size_t nmemb, size_t size)

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
  • Loading branch information
zhijianli88 committed Nov 13, 2024
1 parent 191a5fe commit 401c0d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion librdmacm/examples/cmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
}

nodes = calloc(sizeof *nodes, iter);
nodes = calloc(iter, sizeof *nodes);
if (!nodes) {
perror("calloc");
exit(EXIT_FAILURE);
Expand Down

0 comments on commit 401c0d7

Please sign in to comment.