Then to be conservative I would generally write this like 

    while (PIOS_LSM303_Accel_SetReg(PIOS_LSM303_CTRL_REG4_A, buf | (accel_range & PIOS_LSM3030_RANGE_MASK)) != 0);