Simplify NULL checks

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Use state assignment instead of decrement to improve readability

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Remove unnecessary state decrement

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>