我观察贵公司关于FreeRTOSv202212.01的队列部分源码。发现写入与读出数据项的函数,没有找到关于检测待插入数据是否与队列项数据匹配的问题。请问是不需要进行检测吗?
Google translate gives the following:
I observed your company’s source code for the queue part of FreeRTOSv202212.01. Found the functions for writing and reading data items, but did not find the problem of detecting whether the data to be inserted matches the queue item data. Is there no need for testing?
FreeRTOS queues do not perform any check on the type and copy the number of bytes equal to the size of queue item. It is the responsibility of the application to ensure that the correct item type is posted to the queue.
1 Like
感谢解答,我只是疑惑如果不对类型进行任何检查,数据buf与队列项大小不匹配,memcpy执行的时候造成越界。
Google translate:
Thanks for the answer. I'm just wondering if there is no type check, the data buf does not match the size of the queue item, and memcpy is out of bounds when executed.
Yes that can happen and that would be an application bug.
One thing to note, in C, there is no way to do a check of the type of object passed via a void* pointer. You would need a type specific wrapper for each type you want to have to attempt to validate the data type, but casting, or housing a different wrapper could bypass the check.
原来如此,看了您的解答,我明白了不做空间匹配的原因。