MCPcopy Create free account
hub / github.com/coreboot/coreboot / process_set

Function process_set

util/smmstoretool/main.c:148–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148static int process_set(int argc, char *argv[], const char store_file[])
149{
150 const char *name = NULL;
151 const char *value = NULL;
152 const char *type_str = NULL;
153 const char *guid_str = NULL;
154 bool authenticated_var = false;
155 int opt;
156 while ((opt = getopt(argc, argv, "n:t:v:g:a::")) != -1) {
157 switch (opt) {
158 case 'n':
159 name = optarg;
160 break;
161 case 't':
162 type_str = optarg;
163 break;
164 case 'v':
165 value = optarg;
166 break;
167 case 'g':
168 guid_str = optarg;
169 break;
170 case 'a':
171 authenticated_var = true;
172 break;
173
174 case '?': /* parsing error */
175 print_sub_command_usage(argv[0]);
176 }
177 }
178
179 if (argv[optind] != NULL) {
180 fprintf(stderr, "First unexpected positional argument: %s\n",
181 argv[optind]);
182 print_sub_command_usage(argv[0]);
183 }
184
185 if (name == NULL || value == NULL || type_str == NULL ||
186 guid_str == NULL) {
187 fprintf(stderr, "All options are required\n");
188 print_sub_command_usage(argv[0]);
189 }
190
191 if (name[0] == '\0') {
192 fprintf(stderr, "Variable name can't be empty\n");
193 print_sub_command_usage(argv[0]);
194 }
195
196 EFI_GUID guid;
197 if (!parse_guid(guid_str, &guid)) {
198 fprintf(stderr, "Failed to parse GUID: %s\n", guid_str);
199 return EXIT_FAILURE;
200 }
201
202 enum data_type type;
203 if (!parse_data_type(type_str, &type)) {
204 fprintf(stderr, "Failed to parse type: %s\n", type_str);
205 return EXIT_FAILURE;

Callers

nothing calls this directly

Calls 12

getoptFunction · 0.85
print_sub_command_usageFunction · 0.85
fprintfFunction · 0.85
parse_guidFunction · 0.85
parse_data_typeFunction · 0.85
make_dataFunction · 0.85
storage_openFunction · 0.85
vs_findFunction · 0.85
vs_new_varFunction · 0.85
to_ucharsFunction · 0.85
storage_write_backFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected