[osal]: Change mpp_env string interface

Set get environment string parameter to const char to avoid modification.

Change-Id: Ib5308407fcac2fa58b194fb8df33380efc1487f9
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Herman Chen 2018-08-03 15:56:03 +08:00
parent 723ee1ec2d
commit 6d059f65bf
7 changed files with 12 additions and 13 deletions

View File

@ -45,7 +45,7 @@ RK_S32 os_get_env_u32(const char *name, RK_U32 *value, RK_U32 default_value)
return 0;
}
RK_S32 os_get_env_str(const char *name, char **value, char *default_value)
RK_S32 os_get_env_str(const char *name, const char **value, const char *default_value)
{
// use unsigned char to avoid warnning
static unsigned char env_str[2][PROP_VALUE_MAX + 1];

View File

@ -24,7 +24,7 @@ extern "C" {
#endif
RK_S32 mpp_env_get_u32(const char *name, RK_U32 *value, RK_U32 default_value);
RK_S32 mpp_env_get_str(const char *name, char **value, char *default_value);
RK_S32 mpp_env_get_str(const char *name, const char **value, const char *default_value);
RK_S32 mpp_env_set_u32(const char *name, RK_U32 value);
RK_S32 mpp_env_set_str(const char *name, char *value);

View File

@ -40,7 +40,7 @@ RK_S32 os_get_env_u32(const char *name, RK_U32 *value, RK_U32 default_value)
return 0;
}
RK_S32 os_get_env_str(const char *name, char **value, char *default_value)
RK_S32 os_get_env_str(const char *name, const char **value, const char *default_value)
{
*value = getenv(name);
if (NULL == *value) {

View File

@ -24,7 +24,7 @@ RK_S32 mpp_env_get_u32(const char *name, RK_U32 *value, RK_U32 default_value)
return os_get_env_u32(name, value, default_value);
}
RK_S32 mpp_env_get_str(const char *name, char **value, char *default_value)
RK_S32 mpp_env_get_str(const char *name, const char **value, const char *default_value)
{
return os_get_env_str(name, value, default_value);
}

View File

@ -24,7 +24,7 @@ extern "C" {
#endif
RK_S32 os_get_env_u32(const char *name, RK_U32 *value, RK_U32 default_value);
RK_S32 os_get_env_str(const char *name, char **value, char *default_value);
RK_S32 os_get_env_str(const char *name, const char **value, const char *default_value);
RK_S32 os_set_env_u32(const char *name, RK_U32 value);
RK_S32 os_set_env_str(const char *name, char *value);

View File

@ -25,22 +25,21 @@ char env_test_string[] = "just for debug";
int main()
{
RK_U32 env_debug_u32 = 0x100;
char *env_string_str = env_test_string;
const char *env_str_out = NULL;
mpp_env_set_u32(env_debug, env_debug_u32);
mpp_env_set_str(env_string, env_string_str);
mpp_env_set_str(env_string, env_test_string);
mpp_log("set env: %s to %u\n", env_debug, env_debug_u32);
mpp_log("set env: %s to %s\n", env_string, env_string_str);
mpp_log("set env: %s to %s\n", env_string, env_test_string);
env_debug_u32 = 0;
env_string_str = NULL;
mpp_log("clear local value to zero\n");
mpp_log("start reading env:\n");
mpp_env_get_u32(env_debug, &env_debug_u32, 0);
mpp_env_get_str(env_string, &env_string_str, NULL);
mpp_env_get_str(env_string, &env_str_out, NULL);
mpp_log("get env: %s is %u\n", env_debug, env_debug_u32);
mpp_log("get env: %s is %s\n", env_string, env_string_str);
mpp_log("get env: %s is %s\n", env_string, env_str_out);
return 0;
}

View File

@ -39,7 +39,7 @@ RK_S32 os_get_env_u32(const char *name, RK_U32 *value, RK_U32 default_value)
return 0;
}
RK_S32 os_get_env_str(const char *name, char **value, char *default_value)
RK_S32 os_get_env_str(const char *name, const char **value, const char *default_value)
{
*value = getenv(name);
if (NULL == *value) {