libpfrng: optimize errors handling