keil C 没有goto语句的?

2020-01-23 14:32发布

如题,求解
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
80条回答
NJ8888
2020-01-25 03:39
下面是美国人写的代码

static int csmsh_setserialnum()
{
  char buff[(OEMCFGBASESIZE_SERIAL_NUM*2)+1];
  unsigned int bufflen = (OEMCFGBASESIZE_SERIAL_NUM*2);
  int tmpret = 0;

  buff[(OEMCFGBASESIZE_SERIAL_NUM*2)] = 0x0;

  csmsh_macops->dbg.prompt_string_ser("Enter sevice serial number string (80 chars max)",
                                      (char*)buff, &bufflen);
  /* bounds check user input */
  if(bufflen < 1)
  {
    csmsh_macops->dbg.pr_ser("ERROR: no user input ");
    goto done_exit;
  }
  /* output what the user typed */
  csmsh_macops->dbg.pr_ser("%d chars, data->%s<- ", bufflen, buff);

  /* now call the generic usb string descriptor write function */
  tmpret = csmsh_macops->oemcfg.wrusbstrdesc(OEMCFGBASE_SERIAL_NUM, buff, bufflen);
  if(tmpret != 0)
  {
    csmsh_macops->dbg.pr_ser("ERROR: failed to write string to oem cfg, macerrno = 0x%X ",
                             macerrno);
    goto done_exit;
  }
done_exit:
  return 0;
}

一周热门 更多>