Changeset aa3ca1e in mainline
- Timestamp:
- 2019-06-22T13:26:01Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0d0f1a8
- Parents:
- f31ca47
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/alias/alias.c
rf31ca47 raa3ca1e 65 65 } 66 66 67 static voidset_alias(const char *name, const char *value)67 static errno_t set_alias(const char *name, const char *value) 68 68 { 69 69 odlink_t *alias_link = odict_find_eq(&alias_dict, (void *)name, NULL); … … 74 74 free(data->value); 75 75 data->value = str_dup(value); 76 77 if (data->value == NULL) { 78 cli_error(CL_ENOMEM, "%s: failing to allocate memory for value\n", cmdname); 79 return ENOMEM; 80 } 76 81 } else { 77 82 /* add new value */ 78 83 alias_t *data = (alias_t *)calloc(1, sizeof(alias_t)); 84 if (data == NULL) { 85 cli_error(CL_ENOMEM, "%s: failing to allocate memory for data container\n", cmdname); 86 return ENOMEM; 87 } 88 79 89 data->name = str_dup(name); 90 if (data->name == NULL) { 91 cli_error(CL_ENOMEM, "%s: failing to allocate memory for name\n", cmdname); 92 free(data); 93 return ENOMEM; 94 } 95 80 96 data->value = str_dup(value); 81 97 if (data->value == NULL) { 98 cli_error(CL_ENOMEM, "%s: failing to allocate memory for value\n", cmdname); 99 free(data->name); 100 free(data); 101 return ENOMEM; 102 } 82 103 odict_insert(&data->odict, &alias_dict, NULL); 83 104 } 105 106 return EOK; 84 107 } 85 108 … … 131 154 size_t i; 132 155 for (i = 1; argv[i] != NULL; i++) { 133 char *name = str_dup(argv[i]);156 char *name = argv[i]; 134 157 char *value; 135 158 if ((value = str_chr(name, '=')) != NULL) { 136 159 name[value - name] = '\0'; 160 137 161 if (!validate_name(name)) { 138 162 cli_error(CL_EFAIL, "%s: invalid alias name given\n", cmdname); 139 free(name);140 163 return CMD_FAILURE; 141 164 } 142 165 143 set_alias(name, value + 1); 166 if (set_alias(name, value + 1) != EOK) { 167 return CMD_FAILURE; 168 } 144 169 } else { 145 170 if (!print_alias(name)) { 146 free(name);147 171 return CMD_FAILURE; 148 172 } 149 173 } 150 151 free(name);152 174 } 153 175
Note:
See TracChangeset
for help on using the changeset viewer.