xfs
[Top] [All Lists]

Re: [PATCH 1/8] cleanup: get rid of ASSERT

To: Dave Chinner <david@xxxxxxxxxxxxx>
Subject: Re: [PATCH 1/8] cleanup: get rid of ASSERT
From: Brian Foster <bfoster@xxxxxxxxxx>
Date: Fri, 30 Oct 2015 07:39:51 -0400
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20151029222609.GC10656@dastard>
References: <1444959901-31319-1-git-send-email-david@xxxxxxxxxxxxx> <1444959901-31319-2-git-send-email-david@xxxxxxxxxxxxx> <20151028115121.GA50552@xxxxxxxxxxxxxxx> <20151028223234.GQ8773@dastard> <20151029121333.GA11663@xxxxxxxxxxxxxxx> <20151029222609.GC10656@dastard>
User-agent: Mutt/1.5.23 (2014-03-12)
On Fri, Oct 30, 2015 at 09:26:09AM +1100, Dave Chinner wrote:
> On Thu, Oct 29, 2015 at 08:13:34AM -0400, Brian Foster wrote:
...
> > Then why not try to undef/redef in xfsdump or just rename the #define
> > that's used? I don't care too much either way, I just don't follow why
> > there's a need to change behavior at all to fix a naming conflict.
> > 
> > Are we saying that ASSERT() probably shouldn't exist in userspace (incl.
> > xfsprogs) and we should always use the generic assert() mechanism? Or
> > are we saying ASSERT() can exist in userspace, but it's purely a libxfs
> > thing and should not be exported beyond that (e.g., libxfs can use
> > ASSERT(), actual userspace tools like repair, etc. should eventually use
> > assert())..?
> 
> Precisely this. ASSERT is used in the kernel side libxfs code, and
> so only exists in userspace to support the libxfs code in userspace.
> We don't want the libxfs code in userspace aborting on corrupt
> structures or invalid situations, because we need to
> handle/parse/repair such brokenness. IOWS, the ASSERTs in libxfs/ in
> userspace need to be turned off for userspace to work correctly.
> That's what the DEBUG define in libxfs does.
> 

Indeed.

> That leads to the xfsprogs userspace still needing an assert
> facility - that comes from using assert() and NDEBUG to turn it off
> and on.
> 
> Essentially, ASSERT is internal to libxfs and should not be exported
> anywhere. assert() should used outside libxfs in xfsprogs and other
> XFS code bases.
> 

Makes sense to me. Thanks for the explanation. It would be good if the
commit log description included some of this info. Otherwise, for the
series:

Acked-by: Brian Foster <bfoster@xxxxxxxxxx>

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@xxxxxxxxxxxxx
> 
> _______________________________________________
> xfs mailing list
> xfs@xxxxxxxxxxx
> http://oss.sgi.com/mailman/listinfo/xfs

<Prev in Thread] Current Thread [Next in Thread>