[PATCH 2/6] torture: test FSCTL_SET_SPARSE

Jeremy Allison jra at samba.org
Thu Aug 28 10:45:21 MDT 2014


On Thu, Aug 28, 2014 at 08:56:59AM +0200, David Disseldorp wrote:
> 
> 
> On 28 August 2014 1:42:52 am GMT+02:00, Jeremy Allison <jra at samba.org> wrote:
> >On Wed, Aug 27, 2014 at 03:41:58PM +0200, David Disseldorp wrote:
> >> Check that the FILE_ATTRIBUTE_SPARSE is set following
> >FSCTL_SET_SPARSE.
> >> Also confirm that adding the attribute on create doesn't carry
> >through
> >> to subsequent SMB2_GETINFO_FILE requests.
> >
> >> +static NTSTATUS test_sparse_get(struct torture_context *torture,
> >> +				TALLOC_CTX *mem_ctx,
> >> +				struct smb2_tree *tree,
> >> +				struct smb2_handle fh,
> >> +				bool *_is_sparse)
> >> +{
> >> +	union smb_fileinfo io;
> >> +	NTSTATUS status;
> >> +
> >> +	ZERO_STRUCT(io);
> >> +	io.generic.level = RAW_FILEINFO_BASIC_INFORMATION;
> >> +	io.generic.in.file.handle = fh;
> >> +	status = smb2_getinfo_file(tree, mem_ctx, &io);
> >> +	if (!NT_STATUS_IS_OK(status)) {
> >> +		return status;
> >> +	}
> >> +	*_is_sparse = !!(io.basic_info.out.attrib & FILE_ATTRIBUTE_SPARSE);
> >
> >This line:
> >
> >                      ^^
> >                      ||
> >
> >is weird :-). Double ! Typo ?
> 
> That's intended. It's shorthand for converting the flag to a bool.

Ah, should have git grepped for it in our code first before
complaining :-). It's also used in lib/util/debug.h (but
at least it's mentioned as "strange" there :-).

-------------------------------------------------------------
/* these macros gain us a few percent of speed on gcc */
#if (__GNUC__ >= 3)
/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1
   as its first argument */
#ifndef likely
#define likely(x)   __builtin_expect(!!(x), 1)
#endif
#ifndef unlikely
-------------------------------------------------------------

> Thanks for the review.

No problem, will finish up today !


More information about the samba-technical mailing list