Major refactoring of code based on review comments at
https://review.gluster.org/#/c/8238/1/xlators/mgmt/glusterd/src/glusterd-peer-utils.h

Change-Id: I359bbb237f86b0292a1c8bfc0dc176163585d6c3