Attention is currently required from: jacz@semihalf.com, Duncan Laurie, Jan Dabros. Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/50910 )
Change subject: acpi/acpigen.h: Add more intuitive AML package closing functions ......................................................................
Patch Set 1: Code-Review+1
(5 comments)
Patchset:
PS1:
That is a great use of C scopes, I will have to adopt this practice as well. […]
Yeah, I'm okay with having these functions, especially since one can use them to check if we're closing the right thing.
File src/include/acpi/acpigen.h:
https://review.coreboot.org/c/coreboot/+/50910/comment/17a60302_4bc05d3e PS1, Line 331: inline void acpigen_write_method_end(void) Since `acpigen_write_method_serialized` is also a method, I'd place `acpigen_write_method_end` below both of these.
https://review.coreboot.org/c/coreboot/+/50910/comment/fac86c29_4198ba76 PS1, Line 404: inline void acpigen_write_if_end(void) Same here
https://review.coreboot.org/c/coreboot/+/50910/comment/be08878c_cc43e426 PS1, Line 412: void acpigen_write_else(void); Looks like all calls to `acpigen_write_else` are preceded by an `acpigen_pop_len` call. Unsurprising, I know: the `Else` operator can only appear after an `If` or an `ElseIf` operator.
So, I'd suggest making the `acpigen_write_else` function also pop the if-block. When using scopes in C, this wouldn't look too bad:
acpigen_write_if_lequal_op_int(LOCAL0_OP, 42); { /* Some stuff */ } acpigen_write_else(); acpigen_write_if_lequal_op_int(LOCAL0_OP, 666); { /* More stuff */ } acpigen_write_else(); { /* Even more stuff */ } acpigen_write_if_end();
Of course, this would be best done in a separate patch.
https://review.coreboot.org/c/coreboot/+/50910/comment/3ece992c_73916a51 PS1, Line 413: inline void acpigen_write_else_end(void) IMHO, I'd also close else-blocks with `acpigen_write_if_end`, especially if implementing the suggestion above. I'll let others share their thoughts on this (I don't write acpigen too often).