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

Function sym_set_string_value

util/kconfig/symbol.c:649–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

647}
648
649bool sym_set_string_value(struct symbol *sym, const char *newval)
650{
651 const char *oldval;
652 char *val;
653 int size;
654
655 switch (sym->type) {
656 case S_BOOLEAN:
657 case S_TRISTATE:
658 switch (newval[0]) {
659 case 'y': case 'Y':
660 return sym_set_tristate_value(sym, yes);
661 case 'm': case 'M':
662 return sym_set_tristate_value(sym, mod);
663 case 'n': case 'N':
664 return sym_set_tristate_value(sym, no);
665 }
666 return false;
667 default:
668 ;
669 }
670
671 if (!sym_string_within_range(sym, newval))
672 return false;
673
674 if (!(sym->flags & SYMBOL_DEF_USER)) {
675 sym->flags |= SYMBOL_DEF_USER;
676 sym_set_changed(sym);
677 }
678
679 oldval = sym->def[S_DEF_USER].val;
680 size = strlen(newval) + 1;
681 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
682 size += 2;
683 sym->def[S_DEF_USER].val = val = xmalloc(size);
684 *val++ = '0';
685 *val++ = 'x';
686 } else if (!oldval || strcmp(oldval, newval))
687 sym->def[S_DEF_USER].val = val = xmalloc(size);
688 else
689 return true;
690
691 strcpy(val, newval);
692 free((void *)oldval);
693 sym_clear_all_valid();
694
695 return true;
696}
697
698/*
699 * Find the default value associated to a symbol.

Callers 5

setModelDataMethod · 0.85
conf_stringFunction · 0.85
conf_stringFunction · 0.85
conf_stringFunction · 0.85
renderer_editedFunction · 0.85

Calls 9

sym_set_tristate_valueFunction · 0.85
sym_string_within_rangeFunction · 0.85
sym_set_changedFunction · 0.85
strlenFunction · 0.85
sym_clear_all_validFunction · 0.85
xmallocFunction · 0.70
strcmpFunction · 0.50
strcpyFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected