Просмотр исходного кода

add: 开启Werror=maybe-uninitialized

Wendal Chen 2 лет назад
Родитель
Сommit
6804378ef0
3 измененных файлов с 7 добавлено и 7 удалено
  1. 1 1
      bsp/air105/hal/core_usb_ll_driver.c
  2. 5 5
      bsp/usb/src/core_usb_class_msc_scsi.c
  3. 1 1
      xmake.lua

+ 1 - 1
bsp/air105/hal/core_usb_ll_driver.c

@@ -1439,7 +1439,7 @@ static int prvUSB_SetupEPFifo(HANDLE hUSB)
 {
 	USB_HWCtrlStruct *hwUSB = (USB_HWCtrlStruct *)hUSB;
 	uint8_t i;
-	uint8_t Len;
+	uint8_t Len = 0;
 	uint16_t FifoStart = (64 >> 3);
 	uint16_t UseFifo = 64;
 	//ep0使用默认的64byte

+ 5 - 5
bsp/usb/src/core_usb_class_msc_scsi.c

@@ -278,7 +278,7 @@ CMD_PROC_END:
 
 static void prvUSB_SCSIHandleToDeviceData(USB_EndpointDataStruct *pEpData, MSC_SCSICtrlStruct *pMSC)
 {
-	int32_t Result;
+	int32_t Result = 0;
 	USB_StorageSCSITypeDef *pUserFun = (USB_StorageSCSITypeDef *)pMSC->pSCSIUserFunList;
 	if (pEpData->Len)
 	{
@@ -630,10 +630,10 @@ static int32_t prvSCSI_AllowPreventRemovable(USB_EndpointDataStruct *pEpData, MS
   */
 static int32_t prvSCSI_Read(USB_EndpointDataStruct *pEpData, MSC_SCSICtrlStruct *pMSC)
 {
-	uint32_t BlockNum, BlockSize;
+	uint32_t BlockNum = 0, BlockSize;
 	USB_StorageSCSITypeDef *pUserFun = (USB_StorageSCSITypeDef *)pMSC->pSCSIUserFunList;
 	int ret = pUserFun->GetCapacity(pMSC->CBW.bLUN, &BlockNum, &BlockSize, pMSC->pUserData);
-	uint32_t BlockNums, CurBLKAddress;
+	uint32_t BlockNums = 0, CurBLKAddress;
 	CurBLKAddress = BytesGetBe32(&pMSC->CBW.CB[2]);
 	if (!pMSC->ReadTimer) pMSC->ReadTimer = Timer_Create(prvUSB_MSCTimeout, pMSC, NULL);
 	switch(pMSC->CBW.CB[0])
@@ -711,10 +711,10 @@ static int32_t prvSCSI_Read(USB_EndpointDataStruct *pEpData, MSC_SCSICtrlStruct
   */
 static int32_t prvSCSI_Write(USB_EndpointDataStruct *pEpData, MSC_SCSICtrlStruct *pMSC)
 {
-	uint32_t BlockNum, BlockSize;
+	uint32_t BlockNum = 0, BlockSize;
 	USB_StorageSCSITypeDef *pUserFun = (USB_StorageSCSITypeDef *)pMSC->pSCSIUserFunList;
 	int ret = pUserFun->GetCapacity(pMSC->CBW.bLUN, &BlockNum, &BlockSize, pMSC->pUserData);
-	uint32_t BlockNums, CurBLKAddress;
+	uint32_t BlockNums = 0, CurBLKAddress;
 	CurBLKAddress = BytesGetBe32(&pMSC->CBW.CB[2]);
 	switch(pMSC->CBW.CB[0])
 	{

+ 1 - 1
xmake.lua

@@ -76,7 +76,7 @@ add_asflags("-mcpu=cortex-m4","-mfpu=fpv4-sp-d16","-mfloat-abi=hard","-mthumb","
 add_cxflags("-mcpu=cortex-m4","-mfpu=fpv4-sp-d16","-mfloat-abi=hard","-mthumb","-c","--specs=nano.specs","-ffunction-sections","-fdata-sections","-fstack-usage","-DTRACE_LEVEL=4",{force = true})
 
 add_ldflags("-mcpu=cortex-m4","-mfpu=fpv4-sp-d16","-mfloat-abi=hard","-mthumb","-static","--specs=nano.specs","-Wl,--gc-sections","-Wl,--check-sections","-Wl,--cref","-Wl,--no-whole-archive","-lc_nano","-Wl,--no-whole-archive",{force = true})
-
+add_cxflags("-Werror=maybe-uninitialized")
 
 add_ldflags(" -Wl,--wrap=malloc ",{force = true})
 add_ldflags(" -Wl,--wrap=free ",{force = true})