Attention is currently required from: Tim Wawrzynczak.
Angel Pons has posted comments on this change by Tim Wawrzynczak. ( https://review.coreboot.org/c/coreboot/+/50857?usp=email )
Change subject: sb/intel/common: Refactor _PRT generation to support GSI-based tables ......................................................................
Patch Set 22:
(1 comment)
File src/southbridge/intel/common/rcba_pirq.c:
https://review.coreboot.org/c/coreboot/+/50857/comment/09488d70_bde77377?usp... : PS22, Line 61: pin_irq_map = calloc(sizeof(struct slot_pin_irq_map), MAX_SLOTS * PCI_INT_MAX);
The two calloc calls are not equivalent indeed. The first call, `calloc(sizeof(struct slot_pin_irq_map), MAX_SLOTS * PCI_INT_MAX)`, allocates memory for `sizeof(struct slot_pin_irq_map)` elements, each of size `MAX_SLOTS * PCI_INT_MAX` bytes. In contrast, the second call, `calloc(MAX_SLOTS, sizeof(struct slot_pin_irq_map) * PCI_INT_MAX)`, allocates memory for `MAX_SLOTS` elements, each of size `sizeof(struct slot_pin_irq_map) * PCI_INT_MAX` bytes. Although the total amount of memory allocated is mathematically the same, the second call correctly follows the calloc convention by specifying the number of elements and the size of each element, making it the appropriate and intuitive choice.
Who said this? It tries to sound convincing, but it's a bunch of nonsense. Also, formatting is messed up (I fixed it in my quote)
I said the function calls are equivalent because they allocate the same amount of memory. Changing this won't fix any bugs. But neither of them "follows the calloc convention" (signature is `void *calloc(size_t num, size_t size)`): the `size` parameter would need to be `sizeof(struct slot_pin_irq_map)` or `sizeof(*pin_irq_map)` (the size of one element).
See reply there.