-
Notifications
You must be signed in to change notification settings - Fork 206
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
Pointer arguments to functions that are input only should be declared "const" #59
Comments
Imported from trac issue 28. Created by jphickey on 2015-01-22T09:48:19, last modified: 2019-03-05T14:57:55 |
Trac comment by jphickey on 2015-01-26 16:24:11: Branch "trac-28-const_pointer_args" pushed -- commit [changeset:bed05ea] This adds a "const" designation to the function prototypes where applicable. This set may not be 100% complete, but it gets all the low hanging fruit. |
Trac comment by jphickey on 2015-03-13 16:02:06: DEPENDENCY NOTE: using this change set also requires taking PSP trac 15: [https://babelfish.arc.nasa.gov/trac/cfs_psp/ticket/15] This fixes the PSP calls to adhere to the modified prototypes on the CFE side. There is also a separate merge commit [changeset:2bd5438] that is also required when merging this with the fix for trac #32. These are pushed separately since there has not been a new baseline (yet) that already includes trac 1. |
Trac comment by jphickey on 2015-04-06 11:51:56: This is ready for review/merge The merge changeset for the two parts of this fix can be viewed in [changeset:29c1ec9]. |
Trac comment by sstrege on 2015-04-06 13:18:55: Concur with changes involving the addition of the "const" keyword. The diff did show some other changes that are unrelated to this ticket: cfe_time_utils.h - copyright character changed? cfe_tbl_task_cmds.c - changed PSP_MemCpy to strncpy - I'm OK with this change es_UT.c - removed typecast from function prototypes? |
Trac comment by jphickey on 2015-04-06 13:59:26: My comments to the comments:
However, the change from memcpy() to strncpy() is absolutely necessary here - the former will read past the end of the source string if it is less than CFE_TBL_MAX_FULL_NAME_LEN characters. |
Trac comment by acudmore on 2015-04-07 12:38:18: Concur. |
Trac comment by glimes on 2015-04-07 13:02:50: Tested changesets [changeset:bed05ea51] [changeset:29c1ec922] as part of the ic-2015-03-10 merge. |
Trac comment by glimes on 2015-04-13 15:14:21: Part of integration candidate 2015-03-10, |
Trac comment by glimes on 2016-02-16 13:16:45: Susie confirmed these tickets have been approved for CFE 6.5 |
Trac comment by jhageman on 2019-03-05 14:57:55: Milestone renamed |
Marking the pointer parameter as "const", particularly for string arguments, allows them to be called using string literals or other data that is already constant.
This may make a substantial difference on some targets where the executable can actually be linked to put the read-only data section in ROM rather than RAM. However, in order to do this properly/safely the code must treat this as read-only data. By declaring it "const" the compiler will flag any writes to it.
Changing the prototypes should not affect current usage.
The text was updated successfully, but these errors were encountered: