Hi Jan, > -----Original Message----- > From: Jan Beulich <jbeul...@suse.com> > Subject: Re: [PATCH v2] xen/arm: p2m: Populate pages for GICv2 mapping in > arch_domain_create() > > On 14.10.2022 13:04, Henry Wang wrote: > >> -----Original Message----- > >> From: Jan Beulich <jbeul...@suse.com> > >> > >>> My initial thought is the "else if" part in p2m_set_allocation. It might > >>> be > >>> wrong. Would the code below seems ok to you? > >>> > >>> int err; > >>> > >>> do { > >>> err = p2m_teardown_allocation(d) > >>> } while ( err == -ERESTART ) > >> > >> Sure, one of several ways of doing it. > > > > Thanks for your confirmation. Just to play safe if you have more simple > > Solutions please do raise it. It is a good opportunity for me to learn and > > personally I am not a big fan of either do-while or the introduced "err" > > which is used only by p2m_teardown_allocation(d), considering the > > p2m_final_teardown(d) has a void return type... > > Personally I would probably have written > > while ( p2m_teardown_allocation(d) == -ERESTART ) > /* Nothing - no preemption support here. */;
Thanks very much for the suggestions! I didn't think of the /* */ part and I really like this idea. This said, a quick search of different coding styles and I found [1] mentioned: "Empty loop bodies should use either empty braces or continue. " So I will probably follow... > > or > > while ( p2m_teardown_allocation(d) == -ERESTART ) > continue; /* No preemption support here. */ ...this way. Great experience of learning, thanks! [1] https://google.github.io/styleguide/cppguide.html Kind regards, Henry > > . Otoh with the "err" variable you could ASSERT(!err) after the loop. > > Jan