Re: !! operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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.
_______________________________________________
Gluster-devel mailing list
Gluster-devel@xxxxxxxxxxx
http://www.gluster.org/mailman/listinfo/gluster-devel



[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux