Skip to content

Commit 9d4c1eb

Browse files
committed
FIXUP: invert booleans
1 parent 24f981a commit 9d4c1eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

System/Posix/Fcntl.hsc

+4-4
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fileGetCaching :: Fd -> IO Bool
135135
#if HAVE_O_DIRECT
136136
fileGetCaching (Fd fd) = do
137137
r <- throwErrnoIfMinus1 "fileGetCaching" (c_fcntl_read fd #{const F_GETFL})
138-
return ((r .&. opt_val) /= 0)
138+
return ((r .&. opt_val) == 0)
139139
where
140140
opt_val = #{const O_DIRECT}
141141
#else
@@ -164,14 +164,14 @@ fileSetCaching :: Fd -> Bool -> IO ()
164164
#if HAVE_O_DIRECT
165165
fileSetCaching (Fd fd) val = do
166166
r <- throwErrnoIfMinus1 "fileSetCaching" (c_fcntl_read fd #{const F_GETFL})
167-
let r' | val = fromIntegral r .|. opt_val
168-
| otherwise = fromIntegral r .&. complement opt_val
167+
let r' | val = fromIntegral r .&. complement opt_val
168+
| otherwise = fromIntegral r .|. opt_val
169169
throwErrnoIfMinus1_ "fileSetCaching" (c_fcntl_write fd #{const F_SETFL} r')
170170
where
171171
opt_val = #{const O_DIRECT}
172172
#elif HAVE_F_NOCACHE
173173
fileSetCaching (Fd fd) val = do
174-
throwErrnoIfMinus1_ "fileSetCaching" (c_fcntl_write fd #{const F_NOCACHE} (if val then 1 else 0))
174+
throwErrnoIfMinus1_ "fileSetCaching" (c_fcntl_write fd #{const F_NOCACHE} (if val then 0 else 1))
175175
#else
176176
{-# WARNING fileSetCaching
177177
"operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_O_DIRECT || HAVE_F_NOCACHE @)" #-}

0 commit comments

Comments
 (0)