From: Stefano Stabellini Subject: Re: [PATCH v8 3/8] xen/arm: return int *_dcache_va_range Date: Mon, 20 Oct 2014 17:34:40 +0100 Message-ID: References: <1413798499-28314-3-git-send-email-stefano.stabellini@eu.citrix.com> <1413817046.13796.21.camel@citrix.com> <5445452F02000078000405BD@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XgFxX-0000Kc-7r for xen-devel@lists.xenproject.org; Mon, 20 Oct 2014 16:37:27 +0000 In-Reply-To: <5445452F02000078000405BD@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: julien.grall@citrix.com, xen-devel , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org On Mon, 20 Oct 2014, Jan Beulich wrote: > >>> On 20.10.14 at 16:57, wrote: > >> --- a/xen/arch/arm/mm.c > >> +++ b/xen/arch/arm/mm.c > >> @@ -388,7 +388,7 @@ void flush_page_to_ram(unsigned long mfn) > >> { > >> void *v = map_domain_page(mfn); > >> > >> - clean_and_invalidate_dcache_va_range(v, PAGE_SIZE); > >> + ASSERT(clean_and_invalidate_dcache_va_range(v, PAGE_SIZE) == 0); > > > > Just this one assert? What about all the other callers of > > *_dcache_va_range? There are many many callers under xen/arch/arm, should I really add ASSERT everywhere? Maybe I could just add an ASSERT on the return value within clean_dcache_va_range and clean_and_invalidate_dcache_va_range? Or should I introduce wrappers with the ASSERT? > I'm glad I looked at this reply (I skipped the original one because of > being ARM-only): Uses of ASSERT() like above won't work in non- > debug builds. You have to latch the result into a variable and assert > on it. The fundamental rule is: Expressions passed to ASSERT() must > never have side effects. That's different from BUG_ON(), but even > there Keir advocates not using expressions with side effects, aiui > both to avoid the above mistake (i.e. getting used to doing it the > right way) and to leave open the option of adding a build option to > eliminate the BUG()s and BUG_ON()s too. Jan, well spotted, thanks!