Variable value is contaminated during it is processed. We fix this
issue and prevent a recurrence of this issue by using "const" keyword.
Conflicts:
tizen/src/emul_state.c
Change-Id: I7d50a82a10a6b43b203e78b5394bf3eb8e0231a2
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
(cherry picked from commit
4953ab7043e544828af2f8c4f0dd162158d8c661)
Signed-off-by: Sooyoung Ha <yoosah.ha@samsung.com>
return log_path;
}
#endif
- char *log_path = get_variable("log_path");
+ const char *log_path = get_variable("log_path");
// if "log_path" is not exist, make it first
if (!log_path) {
- char *vms_path = get_variable("vms_path");
- char *vm_name = get_variable("vm_name");
+ const char *vms_path = get_variable("vms_path");
+ const char *vm_name = get_variable("vm_name");
if (!vms_path || !vm_name) {
log_path = NULL;
}
/* drive image file */
const char* get_drive_image_file(void)
{
- char *drive_image_file = get_variable("drive_image_file");
+ const char *drive_image_file = get_variable("drive_image_file");
if (drive_image_file) {
return drive_image_file;
// set emulator resolution
{
- char *resolution = get_variable("resolution");
+ const char *resolution = get_variable("resolution");
if (!resolution) {
fprintf(stderr, "[resolution] is required.\n");
return -1;
QTAILQ_INSERT_TAIL(&variables, var, entry);
}
-char *get_variable(const char * const name)
+const char *get_variable(const char * const name)
{
struct variable *var = NULL;
}
}
-static char *substitute_variables(char *src, bool recursive)
+static char *substitute_variables(const char *src, bool recursive)
{
int i = 0;
int start_index = -1;
// strip ""
int len = strlen(src);
if (src[0] == '"' && src[len - 1] == '"') {
- src[len - 1] = '\0';
- str = g_strdup(src + 1);
+ str = g_strndup(src + 1, len -2);
} else {
- str = g_strdup(src);
+ str = g_strndup(src, len);
}
for (i = 0; str[i]; ++i) {
}
char name[TOKEN_LIMIT];
- char *value = NULL;
+ const char *value = NULL;
char *buf = NULL;
int length;
}
fclose(file);
+
return true;
}
#include "emulator_common.h"
void set_variable(const char * const arg1, const char * const arg2, bool override);
-char *get_variable(const char * const name);
+const char *get_variable(const char * const name);
void reset_variables(void);
bool load_conf(const char * const conf);
bool assemble_emulator_args(int *qemu_argc, char **qemu_argv,