getcommands: Move to resourcemgr/, remove use of SAPI_CLIENT macro, fix error code
The SAPI_CLIENT macro in this function was used to get the error layer /
level right when used from different parts of the TSS. But since
getcommands is only used by the resourcemgr this additional complexity
isn't necessary. We remove the need for this macro by making this
function exclusive to the resourcemgr and move the source file to the
resourcemgr directory.
Additionally the error layer indicator was wrong: the use of
TSS2_ERROR_LEVEL( TSS2_RESMGR_ERROR_LEVEL ) causes the error level shift
to happen twice since the TSS2_RESMGR_ERROR_LEVEL in the SAPI headers
already does the first shift. Applying TSS2_ERROR_LEVEL a second time
here causes the resmgr error level bits to be shifted 32 bits which is
completely out of the TPM_RC. This seems to be the only place this error
is made.
We fix this so that the resmgr layer is identified properly when malloc
fails. We add a unit test that mocks the malloc function forcing a NULL
return value.
Signed-off-by: Philip Tricca <email address hidden>
getcommands: Remove use of malloc function pointer.
This function is only called from the resourcemgr so we really only ever
need the RM specific function pointer. Further, we have no use case to
provide a different allocation function in the RM so this only
complicates the build and makes the code more difficult to read.
Likely this was inteded to be a "future proofing" mechanism in the event
that the RM would be built on systems with different allocation
mechanisms?
Signed-off-by: Philip Tricca <email address hidden>