AnsweredAssumed Answered

5.0 Beta stack: Dead and RNDIS-specific code in usb_cdc.c

Question asked by John Strohm on Feb 11, 2015
Latest reply on Feb 12, 2015 by Wenjun Shi

In file usb_cdc.c, lines 406-410 are as follows:

 

        /* Get count of endpoints for a specific configuration */

        USB_Cdc_Get_Desc_Info(cdc_obj_ptr, USB_CDC_EP_COUNT, &ep_count);

        /* Get count of interfaces for a specific configuration */

        USB_Cdc_Get_Desc_Info(cdc_obj_ptr, USB_CDC_INTERFACE_COUNT, &max_if_count);

        cdc_obj_ptr->max_supported_interfaces = max_if_count;

 

The first call appears to be dead.  ep_count is not used anywhere after it is set.

 

The second call, and the setting of max_supported_interfaces, is RNDIS-specific.  max_supported_interfaces is only used in routine PSTN_Rndis_Message_Set(), in usb_cdc_pstn.c, at lines 615-616:

 

    if(!(cdc_pstn_ptr->current_interface <

         cdc_obj_ptr->max_supported_interfaces))

 

I'd like to suggest that lines 406-407 be deleted, as dead code.

 

I'd further like to suggest that lines 408-410 be guarded as follows:

 

#if USBCFG_DEV_RNDIS_SUPPORT

        /* Get count of interfaces for a specific configuration */

        USB_Cdc_Get_Desc_Info(cdc_obj_ptr, USB_CDC_INTERFACE_COUNT, &max_if_count);

        cdc_obj_ptr->max_supported_interfaces = max_if_count;

#endif

 

And, while we're on the subject, in file usb_cdc.h, lines 130-134:

 

    uint8_t                                      max_supported_interfaces;

#if USBCFG_DEV_RNDIS_SUPPORT  

    /* rndis specific configuration */

    usb_rndis_info_struct_t                      rndis_info;

#endif

 

should probably be rearranged to:

 

#if USBCFG_DEV_RNDIS_SUPPORT

    uint8_t                                      max_supported_interfaces;

    /* rndis specific configuration */

    usb_rndis_info_struct_t                      rndis_info;

#endif

Outcomes