Forum: System Workbench for STM32

No break at the end of case

A couple of internet reference sites like this one say that default is just like case, it can be placed aywhere in the switch.

http://www.c4learn.com/c-programming/c-switch-case-rules/Question

The full function is below.

This is from the bottom of STM example code, usbd_cdc.c.

static uint8_t USBD_CDC_Setup (USBD_HandleTypeDef *pdev,
USBD_SetupReqTypedef *req)
{
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*) pdev->pClassData;
static uint8_t ifalt = 0;

switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
case USB_REQ_TYPE_CLASS :
if (req->wLength)
{
if (req->bmRequest & 0x80)
{
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
(uint8_t *)hcdc->data,
req->wLength);
USBD_CtlSendData (pdev,
(uint8_t *)hcdc->data,
req->wLength);
}
else
{
hcdc->CmdOpCode = req->bRequest;
hcdc->CmdLength = req->wLength;

USBD_CtlPrepareRx (pdev,
(uint8_t *)hcdc->data,
req->wLength);
}

}
else
{
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
(uint8_t*)req,
0);
}
break;

case USB_REQ_TYPE_STANDARD:
switch (req->bRequest)
{
case USB_REQ_GET_INTERFACE :
USBD_CtlSendData (pdev,
&ifalt,
1);
break;

case USB_REQ_SET_INTERFACE :
break;
}

// deafult was commented out as System Workbench issued a warning about no break at the end of case
// default:

break;
}
return USBD_OK;
}