Avoid mixing assignment and returning. "return locked = true;" looks really suspicious, even though it happens to be correct here. Spend an extra statement to make the code clearer, and compilers happier.
Fixes MSVC warning C6282 "Incorrect operator: assignment of constant in Boolean context. Consider using '==' instead."