From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] Xen/atomic: use static inlines instead of macros Date: Mon, 24 Feb 2014 11:29:11 +0000 Message-ID: <530B2D07.60107@citrix.com> References: <1393015311-16167-1-git-send-email-andrew.cooper3@citrix.com> <530B26BC020000780011EA65@nat28.tlf.novell.com> <530B1E3E.6040805@citrix.com> <530B32F7020000780011EAE0@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <530B32F7020000780011EAE0@nat28.tlf.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: KeirFraser , Tim Deegan , StefanoStabellini , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org On 24/02/14 10:54, Jan Beulich wrote: >>>> On 24.02.14 at 11:26, Andrew Cooper wrote: >> On 24/02/14 10:02, Jan Beulich wrote: >>>>>> On 21.02.14 at 21:41, 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. >>>> >>>> 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(). >>> Did you consider leaving these "non-atomic atomic ops" untouched >>> (as they don't involve macro nesting), altering only the "real" ones? >> Yes, but for the sake of three updates at callsites, I felt the benefits >> outweighed the costs. > Except that I don't really see much of a benefit here - the type safety > argument doesn't really count all that much, considering that a wrongly > used type would need to have a suitable field named "counter", which > is unlikely enough to not worry much. > > Jan > An error message of "Expeted atomic_t *, got " is substantially more useful than " doesn't have .counter" or . being an invalid operator in context. ~Andrew