root: fix build by upstream patch

Also refactor the expression a little.

(cherry picked from commit 7ce485ff0fe8f7347db0609d82532bd7dc839c8a)