Posted Aug 20, 2009 9:29 UTC (Thu) by stefani (subscriber, #5846)
Parent article: A new API for kfifo?
About the record handling:
The record functions supports three kinds of record types:
- Records with a fixed size of bytes
- Records with a variable length between 0 and 255 bytes
- Records with a variable length between 0 and 65535 bytes
The return value of the record handling functions is well thought, because it makes it much easier to determinate if the function fails:
- 0 means everything is okay
- a return value lower or equal then the passed length means that the copy_*_user() function has failed
- a value greater the passed length means the record does not fit into the destination buffer/fifo.
It makes no sense to cut off a record, so a return value not equal 0 signals a failure.
Add the *total pointer to the record out functions makes sense, if using variable length records. There must be a way to return the length of the processed record, otherwise the caller don't know the size of the variable length record. You can set the *total pointer to NULL if this value is not requiered.