cgen: swap calloc args

For calloc(nmemb, size), multiplication is commutative, but this still
fixes a -Werror=calloc-transposed-args failure with coreboot's compiler.
This commit is contained in:
Nigel Tao committed 2024-08-12 22:33:33 +10:00
1 parent 721e574398
commit 5d69840f8e
3 files changed
+32 -32

No files matched your search

+1 -1
View File
@@ -1535,7 +1535,7 @@ func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error {
return err
}
b.writes(" {\n")
b.printf("%s%s* x =\n(%s%s*)(calloc(sizeof(%s%s), 1));\n",
b.printf("%s%s* x =\n(%s%s*)(calloc(1, sizeof(%s%s)));\n",
g.pkgPrefix, structName, g.pkgPrefix, structName, g.pkgPrefix, structName)
b.writes("if (!x) {\nreturn NULL;\n}\n")
b.printf("if (%s%s__initialize(\nx, sizeof(%s%s), "+