GNU Astronomy Utilities - Bugs: bug #48609, Modifier 'const' should be used...
You are not allowed to post comments on this tracker with your current authentication level.
bug #48609: Modifier 'const' should be used for function arguments and results where appropriate
Submitter: | Vladimir Markelov <vvm> | ||
Submitted: | Sun 24 Jul 2016 01:56:52 AM UTC | ||
Category: | All Gnuastro | Severity: | 3 - Normal |
Item Group: | Source code | Status: | None |
Privacy: | Public | Assigned to: | None |
Open/Closed: | Open |
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
Carbon-Copy List
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
No changes have been made to this item
Powered by Savane 3.13-758e.
Corresponding source code
A lot of functions takes pointers to data and returns pointers. It would be good to mark 'const' pointers if a function does not change the data or a caller should not change the returned data.
Why:
1. It will be a good hint for a user - a person can easily see if a function changes his/her data or function just reads them
2. A compiler can be a real helper and warn a user if the user tries to change the data(returned by a function) that should be changed at all
A good example for #2 is function 'hdutypestring'. It returns 'char*' but really it returns a pointer to read-only data, so a client code will likely to crash if, e.g, the client code tries to change the returned value in place. A compiler warns the user in this case about casting a 'const char*' to 'char *'.