C语言错误代码集锦
1 for中死循环
1 static int8_t FW_Check_update(uint32_t sr_addr,uint32_t dst_addr,uint32_t size) 2 { 3 #define FLASH_RSIZE 256 4 uint32_t offset =0; 5 uint32_t fw_size =size; 6 uint32_t ramsource[FLASH_RSIZE]={0}; 7 volatile uint32_t flashdestination = dst_addr; 8 uint16_t rsize =FLASH_RSIZE; 9 10 FLASH_If_Erase(APP_START_PAGE,APP_PAGE_SIZE); 11 while(offset < fw_size) 12 { 13 if((fw_size - offset) < (FLASH_RSIZE*4)) 14 { 15 uint32_t temp=fw_size - offset; 16 rsize =((temp%4)==0)?(temp/4):(temp/4 +1); 17 //rsize =(fw_size - offset)/4; 18 } 19 for(uint8_t i=0;i < rsize;i++) 20 { 21 ramsource[i]=STMFLASH_ReadWord(sr_addr +offset+i*4); 22 } 23 24 if (FLASH_If_Write(&flashdestination, ramsource,rsize) == FLASHIF_OK) 25 { 26 offset +=rsize*4; 27 }else{ 28 printf_debug("boot:write app flash failed!!! \n\r"); 29 return 0; 30 } 31 } 32 return 1; 33 }
2 形参过程中改变: