Skip to content

Commit

Permalink
lib: fix calloc warning on recent compiler
Browse files Browse the repository at this point in the history
Fix the following compiler warning:
```
lib/elf_py.c: In function _elffile_load_:
lib/elf_py.c:1310:34: warning: _calloc_ sizes specified with _sizeof_ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
 1310 |         w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum);
      |                                  ^~~~~~~~
lib/elf_py.c:1310:34: note: earlier argument should specify number of elements, later size of each element
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
  • Loading branch information
rzalamena committed Sep 30, 2024
1 parent 8b1b531 commit 660146b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/elf_py.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ static PyObject *elffile_load(PyTypeObject *type, PyObject *args,
}
#endif

w->sects = calloc(sizeof(PyObject *), w->ehdr->e_shnum);
w->sects = calloc(w->ehdr->e_shnum, sizeof(PyObject *));
w->n_sect = w->ehdr->e_shnum;

return (PyObject *)w;
Expand Down

0 comments on commit 660146b

Please sign in to comment.