From: Ian Campbell Subject: Re: [PATCH] Xen/atomic: use static inlines instead of macros Date: Mon, 24 Feb 2014 11:50:38 +0000 Message-ID: <1393242638.16570.57.camel@kazak.uk.xensource.com> References: <1393015311-16167-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1393015311-16167-1-git-send-email-andrew.cooper3@citrix.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: Andrew Cooper Cc: Stefano Stabellini , Tim Deegan , Keir Fraser , Jan Beulich , Xen-devel List-Id: xen-devel@lists.xenproject.org On Fri, 2014-02-21 at 20:41 +0000, Andrew Cooper wrote: > This is some coverity-inspired tidying. > > Coverity has some grief analysing the call sites of atomic_read(). This is > believed to be a bug in Coverity itself when expanding the nested macros, but > there is no legitimate reason for it to be a macro in the first place. > > This patch changes {,_}atomic_{read,set}() from being macros to being static > inline functions, thus gaining some type safety. > > One issue which is not immediatly obvious is that the non-atomic varients take > their atomic_t at a different level of indirection to the atomic varients. "variants" and "immediately" > This is not suitable for _atomic_set() (when used to initialise an atomic_t) > which is converted to take its parameter as a pointer. One callsite of > _atomic_set() is updated, while the other two callsites are updated to > ATOMIC_INIT(). > > Signed-off-by: Andrew Cooper > CC: Keir Fraser > CC: Jan Beulich > CC: Ian Campbell > CC: Stefano Stabellini > CC: Tim Deegan > > --- > > This is compile-tested on arm32 and 64 Thanks! > +static inline void atomic_set(atomic_t *v, int i) > +{ > + v->counter = i; > +} > + > +static inline void _atomic_set(atomic_t *v, int i) > +{ > + v->counter = i; > +} Are these now the same on purpose? (previously one took a pointer and the other the actual variable). I don't have any especially strong feelings on the patch generally. If x86 is going to change then I suppose ARM might as well do so for consistency. Ian.