Fix masked err in portmapper

Defining err as named return parameter will make sure the variable gets
assigned before returning and thus avoid masking

This (might) fix #6904. Testing that now and will update PR.