Possible BUG in USB 5.0 Stack (yes, another one)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Possible BUG in USB 5.0 Stack (yes, another one)

跳至解决方案
961 次查看
johnstrohm
Contributor III

In file usb_dev.c, lines 276-278, I find the following:

            if((event->direction == USB_RECV) && (event->buffer_ptr != NULL))

                OS_dcache_invalidate_mlines((void*)event->buffer_ptr,event->len);

            service_ptr->service(event,service_ptr->arg);

In file adapter_bm.h, line 64, I find the following:

#define OS_dcache_invalidate_mlines(p,n)

The combination of these lines looks, to me, suspiciously like one of those old-time cartoon bombs, with the big,black sphere, and the fuse sizzling away.  The hapless customer who attempts to use the library on bare metal, without MQX, is likely to find himself chasing an interesting problem.  Once the preprocessor does its thing, the compiler will see:

            if((event->direction == USB_RECV) && (event->buffer_ptr != NULL))

                service_ptr->service(event,service_ptr->arg);  /* indentation added to emphasize issue */


which is probably not exactly what is wanted, if the direction happened to be USB_SEND.

May I respectfully suggest the following modification?

            if((event->direction == USB_RECV) && (event->buffer_ptr != NULL))

            {

                OS_dcache_invalidate_mlines((void*)event->buffer_ptr,event->len);

            }

            service_ptr->service(event,service_ptr->arg);

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
800 次查看
makeshi
NXP Employee
NXP Employee

Firstly thanks for your raising the problem and help us improve the USB’s stack’s quality.  Since there is a “;” , the combination of  these line by compiler will be to:

if((event->direction == USB_RECV) && (event->buffer_ptr != NULL))

;

service_ptr->service(event,service_ptr->arg); 

So it will not impact the functionality of code. But I appreciate your code that you suggest change to. Such code is more clear and unambiguous. We accept it and change it in our stack.

在原帖中查看解决方案

0 项奖励
回复
2 回复数
801 次查看
makeshi
NXP Employee
NXP Employee

Firstly thanks for your raising the problem and help us improve the USB’s stack’s quality.  Since there is a “;” , the combination of  these line by compiler will be to:

if((event->direction == USB_RECV) && (event->buffer_ptr != NULL))

;

service_ptr->service(event,service_ptr->arg); 

So it will not impact the functionality of code. But I appreciate your code that you suggest change to. Such code is more clear and unambiguous. We accept it and change it in our stack.

0 项奖励
回复
800 次查看
johnstrohm
Contributor III

Thank you very much for the clarification.

I missed the semicolon.  You're right, the semicolon makes it safe.  It still bothers me.

Thank you for accepting the change suggestion.

0 项奖励
回复