[PATCH i-g-t v2 2/4] assembler: fix calloc calls with inverted arguments

Kamil Konieczny kamil.konieczny at linux.intel.com
Wed Apr 10 15:13:11 UTC 2024


Hi Mauro,
On 2024-04-10 at 16:42:36 +0200, Mauro Carvalho Chehab wrote:
> From: Mauro Carvalho Chehab <mchehab at kernel.org>
> 
> The new gcc version 14 now complains when calloc is called
> with inverted arguments. use the script from:
> a0ee73a8f359 ("benchmarks: fix calloc calls with inverted arguments")
> 
> To fix it.

imho better way would be to say:

This is fixed with the help of the script from:
a0ee73a8f359 ("benchmarks: fix calloc calls with inverted arguments")

With or without it:

Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab at kernel.org>
> ---
>  assembler/gram.y | 6 +++---
>  assembler/main.c | 2 +-
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/assembler/gram.y b/assembler/gram.y
> index 77975e072896..79873b222253 100644
> --- a/assembler/gram.y
> +++ b/assembler/gram.y
> @@ -216,7 +216,7 @@ brw_program_add_instruction(struct brw_program *p,
>  {
>      struct brw_program_instruction *list_entry;
>  
> -    list_entry = calloc(sizeof(struct brw_program_instruction), 1);
> +    list_entry = calloc(1, sizeof(struct brw_program_instruction));
>      list_entry->type = GEN4ASM_INSTRUCTION_GEN;
>      list_entry->insn.gen = instruction->insn.gen;
>      brw_program_append_entry(p, list_entry);
> @@ -228,7 +228,7 @@ brw_program_add_relocatable(struct brw_program *p,
>  {
>      struct brw_program_instruction *list_entry;
>  
> -    list_entry = calloc(sizeof(struct brw_program_instruction), 1);
> +    list_entry = calloc(1, sizeof(struct brw_program_instruction));
>      list_entry->type = GEN4ASM_INSTRUCTION_GEN_RELOCATABLE;
>      list_entry->insn.gen = instruction->insn.gen;
>      list_entry->reloc = instruction->reloc;
> @@ -239,7 +239,7 @@ static void brw_program_add_label(struct brw_program *p, const char *label)
>  {
>      struct brw_program_instruction *list_entry;
>  
> -    list_entry = calloc(sizeof(struct brw_program_instruction), 1);
> +    list_entry = calloc(1, sizeof(struct brw_program_instruction));
>      list_entry->type = GEN4ASM_INSTRUCTION_LABEL;
>      list_entry->insn.label.name = strdup(label);
>      brw_program_append_entry(p, list_entry);
> diff --git a/assembler/main.c b/assembler/main.c
> index 2d39d4536a7f..77cc98b80d21 100644
> --- a/assembler/main.c
> +++ b/assembler/main.c
> @@ -397,7 +397,7 @@ int main(int argc, char **argv)
>  	    if (entry1 && is_label(entry1) && is_entry_point(entry1)) {
>  		// insert NOP instructions until (inst_offset+1) % 4 == 0
>  		while (((inst_offset+1) % 4) != 0) {
> -		    tmp_entry = calloc(sizeof(*tmp_entry), 1);
> +		    tmp_entry = calloc(1, sizeof(*tmp_entry));
>  		    tmp_entry->insn.gen.header.opcode = BRW_OPCODE_NOP;
>  		    entry->next = tmp_entry;
>  		    tmp_entry->next = entry1;
> -- 
> 2.44.0
> 


More information about the igt-dev mailing list