程序遇到return语句不返回吗??

[复制链接]
3432|5
 楼主| gushiyi 发表于 2010-11-15 11:33 | 显示全部楼层 |阅读模式
单步运行的步骤大概是下面这个样子的,运行到return语句为什么会不跳出这个函数呢?而是继续返回到函数里面,这个是ADS1.2环境下,是uc/fs源代码里的一个函数?为什么执行完return还不结束呢?红色是单步的过程……

int FS__lb_write(const FS__device_type *pDriver, FS_u32 Unit, FS_u32 Sector, void *pBuffer) {
  int x;
  if (pDriver->dev_write) {
    FS_X_OS_LockDeviceOp(pDriver, Unit);
    x = (pDriver->dev_write)(Unit, Sector, pBuffer);
#if FS_USE_LB_READCACHE
    if (x==0) {
      _FS_LB_UpdateInCache(pDriver, Unit, Sector, pBuffer);
    }
    else {
      _FS_LB_ClearCache(pDriver, Unit);
    }
#endif  /* FS_USE_LB_READCACHE */
    FS_X_OS_UnlockDeviceOp(pDriver, Unit);
    return x;
  }
  return -1;
}



int FS__lb_write(const FS__device_type *pDriver, FS_u32 Unit, FS_u32 Sector, void *pBuffer) {
  int x;
  if (pDriver->dev_write) {
    FS_X_OS_LockDeviceOp(pDriver, Unit);
    x = (pDriver->dev_write)(Unit, Sector, pBuffer);
#if FS_USE_LB_READCACHE
    if (x==0) {
      _FS_LB_UpdateInCache(pDriver, Unit, Sector, pBuffer);
    }
    else {
      _FS_LB_ClearCache(pDriver, Unit);
    }
#endif  /* FS_USE_LB_READCACHE */
    FS_X_OS_UnlockDeviceOp(pDriver, Unit);
    return x;
  }
  return -1;
}



int FS__lb_write(const FS__device_type *pDriver, FS_u32 Unit, FS_u32 Sector, void *pBuffer) {
  int x;
  if (pDriver->dev_write) {
    FS_X_OS_LockDeviceOp(pDriver, Unit);
    x = (pDriver->dev_write)(Unit, Sector, pBuffer);
#if FS_USE_LB_READCACHE
    if (x==0) {
      _FS_LB_UpdateInCache(pDriver, Unit, Sector, pBuffer);
    }
    else {
      _FS_LB_ClearCache(pDriver, Unit);
    }
#endif  /* FS_USE_LB_READCACHE */
    FS_X_OS_UnlockDeviceOp(pDriver, Unit);
    return x;
  }
  return -1;
}



int FS__lb_write(const FS__device_type *pDriver, FS_u32 Unit, FS_u32 Sector, void *pBuffer) {
  int x;
  if (pDriver->dev_write) {
    FS_X_OS_LockDeviceOp(pDriver, Unit);
    x = (pDriver->dev_write)(Unit, Sector, pBuffer);
#if FS_USE_LB_READCACHE
    if (x==0) {
      _FS_LB_UpdateInCache(pDriver, Unit, Sector, pBuffer);
    }
    else {
      _FS_LB_ClearCache(pDriver, Unit);
    }
#endif  /* FS_USE_LB_READCACHE */
    FS_X_OS_UnlockDeviceOp(pDriver, Unit);
    return x;
  }
  return -1;
}


int FS__lb_write(const FS__device_type *pDriver, FS_u32 Unit, FS_u32 Sector, void *pBuffer) {
  int x;
  if (pDriver->dev_write) {
    FS_X_OS_LockDeviceOp(pDriver, Unit);
    x = (pDriver->dev_write)(Unit, Sector, pBuffer);
#if FS_USE_LB_READCACHE
    if (x==0) {
      _FS_LB_UpdateInCache(pDriver, Unit, Sector, pBuffer);
    }
    else {
      _FS_LB_ClearCache(pDriver, Unit);
    }
#endif  /* FS_USE_LB_READCACHE */
    FS_X_OS_UnlockDeviceOp(pDriver, Unit);
    return x;
  }
  return -1;
}



int FS__lb_write(const FS__device_type *pDriver, FS_u32 Unit, FS_u32 Sector, void *pBuffer) {
  int x;
  if (pDriver->dev_write) {
    FS_X_OS_LockDeviceOp(pDriver, Unit);
    x = (pDriver->dev_write)(Unit, Sector, pBuffer);
#if FS_USE_LB_READCACHE
    if (x==0) {
      _FS_LB_UpdateInCache(pDriver, Unit, Sector, pBuffer);
    }
    else {
      _FS_LB_ClearCache(pDriver, Unit);
    }
#endif  /* FS_USE_LB_READCACHE */
    FS_X_OS_UnlockDeviceOp(pDriver, Unit);
    return x;
  }
  return -1;
}
liang7143 发表于 2010-11-15 12:41 | 显示全部楼层
应该是未满足if的条件
未执行return语句
 楼主| gushiyi 发表于 2010-11-15 14:27 | 显示全部楼层
我的意思是说程序为什么会执行到return -1呢?!
即使是这样,执行到return -1后是不是应该就跳出该函数了呢?!
hgjinwei 发表于 2010-11-15 19:06 | 显示全部楼层
crazyleen 发表于 2010-11-18 20:07 | 显示全部楼层
。。。。。。。。。。。。。。。。。。。。。。
mcu9999 发表于 2010-11-18 21:51 | 显示全部楼层
问问艾弗森
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

41

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部