The type of res is `BOOL`, so you should compare against `FALSE` instead of `0`. Or you can use `if (!res)`.

There are a few places this needs to be fixed.