Replacing CHECK_BOUNDS macro with inline check_bounds function. Change-Id: I8437113da256088576bf66401186e35125089c03