On 10.04.2025 00:24, Denis Mukhin wrote: > On Tuesday, April 8th, 2025 at 9:07 AM, Alejandro Vallejo <agarc...@amd.com> > wrote: >> --- a/xen/arch/x86/domain-builder/fdt.c >> +++ b/xen/arch/x86/domain-builder/fdt.c >> @@ -193,6 +193,25 @@ static int __init process_domain_node( >> bd->domid = (domid_t)val; >> >> printk(" domid: %d\n", bd->domid); >> >> } >> + else if ( strncmp(prop_name, "mode", name_len) == 0 ) >> + { >> + if ( fdt_prop_as_u32(prop, &bd->mode) != 0 ) >> >> + { >> + printk(" failed processing mode for domain %s\n", name); >> + return -EINVAL; >> + } >> + >> + printk(" mode: "); >> + if ( !(bd->mode & BUILD_MODE_PARAVIRT) ) >> >> + { >> + if ( bd->mode & BUILD_MODE_ENABLE_DM ) >> >> + printk("HVM\n"); >> + else >> + printk("PVH\n"); >> + } >> + else >> + printk("PV\n"); >> + } >> } > > I would re-write so the positive condition is processed first, e.g.: > > if ( bd->mode & BUILD_MODE_PARAVIRT ) > printk("PV\n"); > else if ( bd->mode & BUILD_MODE_ENABLE_DM ) > printk("HVM\n"); > else > printk("PVH\n"); > > I think it will reduce indentation and make code block a bit easier to read.
I agree, except it's not so much the "positive condition" but "can be written as if/else-if sequence". Jan