bugGNU 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
Priority:  5 - Normal Item Group:  Source code
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open

Discussion

Sun 24 Jul 2016 01:56:52 AM UTC, original submission:  

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 *'.

Vladimir Markelov <vvm>

 

Attached Files

This item currently has no attached files.

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

Carbon-Copy List
  • -email is unavailable- added by vvm (Submitted the item)
  •  

    Votes

    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.

     

    History

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.16-8b18.
    Corresponding source code