_io_tfs_install and const char *

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

_io_tfs_install and const char *

735 Views
razed11
Contributor V

Does this routine modify the first argument? If not why is it not const?

_io_tfs_install(TFS_ROOT, tfs_data);

Thanks,

Kenny

0 Kudos
Reply
3 Replies

520 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Kenny

Please see the function  _io_dev_install_ext(char *identifier,....),

you can see  this line  "if (identifier[i] == IO_DEV_DELIMITER)".    if identifier is const , maybe there will be a compiler error.

   /* Search for delimiter */

   for (i = 0; i < IO_MAXIMUM_NAME_LENGTH; i++) {

      if (identifier[i] == IO_DEV_DELIMITER) {

         found++;

      } else if (identifier[i] == '\0') {

         break;

      } /* Endif */

   } /* Endfor */

    


Have a great day,
Daniel

0 Kudos
Reply

520 Views
razed11
Contributor V

Thanks Daniel. This doesn't really answer the question. I understand that it will create a compiler warning. I'm suggesting that if the routine doesn't modify the value that the interface should declare identifier as const. That allows me to use:

static const char *IDENTIFIER = "tfs:";

Otherwise I have to copy this to a buffer and it is clumsy for the client. A string literal will not create a compiler error even though it is technically const or at least not ensured to be. That is for historical reasons.

If the interface is changed to const char * then it is backward compatible. Using a literal is not good practice in my opinion especially if it must be used more than once.

I suppose this is less of a question and more of a feature request.

Kenny

0 Kudos
Reply

520 Views
danielchen
NXP TechSupport
NXP TechSupport

I understand, I will check your request with developers

0 Kudos
Reply