root: fix build by upstream patch

Also refactor the expression a little.