Skip to content
  • David Howells's avatar
    VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb) · bc98a42c
    David Howells authored
    
    
    Firstly by applying the following with coccinelle's spatch:
    
    	@@ expression SB; @@
    	-SB->s_flags & MS_RDONLY
    	+sb_rdonly(SB)
    
    to effect the conversion to sb_rdonly(sb), then by applying:
    
    	@@ expression A, SB; @@
    	(
    	-(!sb_rdonly(SB)) && A
    	+!sb_rdonly(SB) && A
    	|
    	-A != (sb_rdonly(SB))
    	+A != sb_rdonly(SB)
    	|
    	-A == (sb_rdonly(SB))
    	+A == sb_rdonly(SB)
    	|
    	-!(sb_rdonly(SB))
    	+!sb_rdonly(SB)
    	|
    	-A && (sb_rdonly(SB))
    	+A && sb_rdonly(SB)
    	|
    	-A || (sb_rdonly(SB))
    	+A || sb_rdonly(SB)
    	|
    	-(sb_rdonly(SB)) != A
    	+sb_rdonly(SB) != A
    	|
    	-(sb_rdonly(SB)) == A
    	+sb_rdonly(SB) == A
    	|
    	-(sb_rdonly(SB)) && A
    	+sb_rdonly(SB) && A
    	|
    	-(sb_rdonly(SB)) || A
    	+sb_rdonly(SB) || A
    	)
    
    	@@ expression A, B, SB; @@
    	(
    	-(sb_rdonly(SB)) ? 1 : 0
    	+sb_rdonly(SB)
    	|
    	-(sb_rdonly(SB)) ? A : B
    	+sb_rdonly(SB) ? A : B
    	)
    
    to remove left over excess bracketage and finally by applying:
    
    	@@ expression A, SB; @@
    	(
    	-(A & MS_RDONLY) != sb_rdonly(SB)
    	+(bool)(A & MS_RDONLY) != sb_rdonly(SB)
    	|
    	-(A & MS_RDONLY) == sb_rdonly(SB)
    	+(bool)(A & MS_RDONLY) == sb_rdonly(SB)
    	)
    
    to make comparisons against the result of sb_rdonly() (which is a bool)
    work correctly.
    
    Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
    bc98a42c