Skip to content

Commit

Permalink
lib: Fix calloc arguments that are in the wrong order
Browse files Browse the repository at this point in the history
Calloc arguments should be (number of items, size of item) but
a few of these are the wrong way around, fix them.

Signed-off-by: Colin Ian King <[email protected]>
  • Loading branch information
ColinIanKing committed Jan 6, 2025
1 parent 3bae201 commit 7930925
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ acpi_get_irdt_chms(struct acpi_table_irdt_device *dev,
size_t chms_len = dev->length - dss_size;

*num = chms_len / sizeof(struct acpi_table_irdt_chms);
*chms = calloc(sizeof(struct acpi_table_irdt_chms *), *num);
*chms = calloc(*num, sizeof(struct acpi_table_irdt_chms *));
if (!*chms) {
LOG_ERROR("Memory allocation failed!\n");
*num = 0;
Expand Down
4 changes: 2 additions & 2 deletions lib/iordt.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,13 @@ iordt_init(const struct pqos_cap *cap, struct pqos_devinfo **devinfo)

acpi_print(table);

m_devinfo = (struct pqos_devinfo *)calloc(sizeof(*m_devinfo), 1);
m_devinfo = (struct pqos_devinfo *)calloc(1, sizeof(*m_devinfo));
if (m_devinfo == NULL) {
acpi_free(table);
return PQOS_RETVAL_ERROR;
}

m_mmioinfo = (struct iordt_mmioinfo *)calloc(sizeof(*m_mmioinfo), 1);
m_mmioinfo = (struct iordt_mmioinfo *)calloc(1, sizeof(*m_mmioinfo));
if (m_mmioinfo == NULL) {
acpi_free(table);
free(m_devinfo);
Expand Down

0 comments on commit 7930925

Please sign in to comment.