Commit 6f972c9f authored by Eric Cano's avatar Eric Cano
Browse files

TPSRV-4:

Updated documentation which was inaccurate about padding of the strings in SCSI structures. Added comments around the correponding helper function.
parent 80cc337c
......@@ -251,7 +251,10 @@ std::string toString(const char(& t)[n]);
\end{lstlisting}
\end{table}
Those arrays are 0-padded, but may not be 0 terminated used completely. It is seen in listing \ref{SCSI_struct_usage}.
Those arrays are space-padded, and may not be 0 terminated. It is seen in listing \ref{SCSI_struct_usage}.
The helper function extracts the string, getting rid of potential zeros at the end,
and managing the fixed length. They keep the space-padding at the end of the extracted
function.
To avoid literals in the code, which forces anyone reading it to do tedious lookups,
the SCSI constants are also defined as constants in the code. See listing \ref{SCSI_consts}.
......
......@@ -852,6 +852,15 @@ namespace SCSI {
};
template <size_t n>
/**
* Extract a string from a fixed size array. This function
* gets rid of zeros in array and stops the extracted string
* there. In SCSI, the arrays are space padded, so the string
* should have a size equal to n usually. This function is templated
* to manage the fixed-size array in the SCSI structures conveniently.
* @param t array pointer to the char array.
* @return the extracted string.
*/
std::string toString(const char(& t)[n]) {
std::stringstream r;
r.write(t, std::find(t, t + n, '\0') - t);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment