Fix 'The scope of the variable 'num_caps' can be reduced.'
Fix 'The scope of the variable 'caps' can be reduced.'
Fix 'The scope of the variable 'root_fd' can be reduced.'