fix warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]