Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CF - Incorrect cast in test functions #46

Closed
jphickey opened this issue Nov 23, 2021 · 1 comment · Fixed by #76
Closed

CF - Incorrect cast in test functions #46

jphickey opened this issue Nov 23, 2021 · 1 comment · Fixed by #76
Milestone

Comments

@jphickey
Copy link
Contributor

This issue was imported from the GSFC issue tracking system

Imported from: [GSFCCFS-1782] CF - Incorrect cast in test functions
Originally submitted by: Hickey, Joseph P. (GSFC-582.0)[VANTAGE SYSTEMS INC] on Tue Nov 16 17:11:06 2021

Original Description:
Some CF test funtions incorrectly cast the pdu_header_t as a different type of header, for example inside 'Test_CF_CFDP_RecvIdle_CheckOf_PDU_HDR_FLAGS_TYPE_Returns_false_But_fdh_directive_code_IsNot_PDU_METADATA_SendEventAnd_Increment_recv_error' it does this:

    ((pdu_file_directive_header_t*)&dummy_msg.pdu_r_msg.ph)->directive_code = Any_file_directive_t_Except(PDU_METADATA);

The problem here is that the pdu_file_directive_header_t should _follow_ the standard pdu_header_t (ph), as it is an extension of this header, it does not replace this header. As a result this is not writing the value in the location expected.

@jphickey
Copy link
Contributor Author

Imported comment by internal user on Tue Nov 16 19:07:44 2021

Another example/form of this same issue appears in Test_CF_CFDP_R2_GapCompute_WhenGiven_c_size_IsGreaterThan_0_Increment_gap_counter, where it has:

pdu_nak_t dummy_nak;

followed by:

dummy_args.ph = (pdu_header_t*)&dummy_nak;

The case to (pdu_header_t*) here is not valid, because pdu_nak_t is an extension of pdu_header_t, not a replacement of it.

A more correct way to declare the buffer would be:

struct

{ pdu_header_t ph; pdu_nak_t nak; } dummy;

And then simply take the address of the ph and nak members, respectively.

astrogeco added a commit that referenced this issue Dec 8, 2021
Fix #44, #46, instantiate properly sized and aligned buffers
@skliper skliper added this to the Draco milestone Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants