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

Function fmap_flags_to_string

util/cbfstool/flashmap/fmap.c:221–251  ·  view source on GitHub ↗

convert raw flags field to user-friendly string */

Source from the content-addressed store, hash-verified

219
220/* convert raw flags field to user-friendly string */
221char *fmap_flags_to_string(uint16_t flags)
222{
223 char *str = NULL;
224 unsigned int i, total_size;
225
226 str = malloc(1);
227 str[0] = '\0';
228 total_size = 1;
229
230 for (i = 0; i < sizeof(flags) * CHAR_BIT; i++) {
231 if (!flags)
232 break;
233
234 if (flags & (1 << i)) {
235 const char *tmp = val2str(1 << i, flag_lut);
236
237 total_size += strlen(tmp);
238 str = realloc(str, total_size);
239 strcat(str, tmp);
240
241 flags &= ~(1 << i);
242 if (flags) {
243 total_size++;
244 str = realloc(str, total_size);
245 strcat(str, ",");
246 }
247 }
248 }
249
250 return str;
251}
252
253/* allocate and initialize a new fmap structure */
254struct fmap *fmap_create(uint64_t base, uint32_t size, uint8_t *name)

Callers 2

fmap_printFunction · 0.85

Calls 5

val2strFunction · 0.85
strlenFunction · 0.85
reallocFunction · 0.85
strcatFunction · 0.85
mallocFunction · 0.50

Tested by 1