[Gluster-devel] !! operator
Jeff Darcy
jdarcy at redhat.com
Sat Apr 2 15:08:27 UTC 2016
> I found a !! in glusterfs sources. Is it a C syntax I do not know, a
> bug, or just a weird syntax?
>
> xlators/cluster/afr/src/afr-inode-write.c:
> local->stable_write = !!((fd->flags|flags)&(O_SYNC|O_DSYNC));
It's a common idiom in the Linux kernel/coreutils community. I
thought it was in BSD too. It's a convenient way to coerce any
arbitrary non-zero integer value into a specific value of one,
for code that uses integers as booleans. I wouldn't assume it's
a bug, since that seems to be precisely what's called for in the
snippet you provided, but I guess that means it's weird syntax.
More information about the Gluster-devel
mailing list