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

Function conf_write_defconfig

util/kconfig/confdata.c:869–940  ·  view source on GitHub ↗

* Write out a minimal config. * All values that has default values are skipped as this is redundant. */

Source from the content-addressed store, hash-verified

867 * All values that has default values are skipped as this is redundant.
868 */
869int conf_write_defconfig(const char *filename)
870{
871 struct symbol *sym;
872 struct menu *menu;
873 FILE *out;
874
875 out = fopen(filename, "w");
876 if (!out)
877 return 1;
878
879 sym_clear_all_valid();
880
881 /* Traverse all menus to find all relevant symbols */
882 menu = rootmenu.list;
883
884 while (menu != NULL)
885 {
886 sym = menu->sym;
887 if (sym == NULL) {
888 if (!menu_is_visible(menu))
889 goto next_menu;
890 } else if (!sym_is_choice(sym)) {
891 sym_calc_value(sym);
892 if (!(sym->flags & SYMBOL_WRITE))
893 goto next_menu;
894 sym->flags &= ~SYMBOL_WRITE;
895 /* If we cannot change the symbol - skip */
896 if (!sym_is_changeable(sym))
897 goto next_menu;
898 /* If symbol equals to default value - skip */
899 if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
900 goto next_menu;
901
902 /*
903 * If symbol is a choice value and equals to the
904 * default for a choice - skip.
905 * But only if value is bool and equal to "y" and
906 * choice is not "optional".
907 * (If choice is "optional" then all values can be "n")
908 */
909 if (sym_is_choice_value(sym)) {
910 struct symbol *cs;
911 struct symbol *ds;
912
913 cs = prop_get_symbol(sym_get_choice_prop(sym));
914 ds = sym_choice_default(cs);
915 if (!sym_is_optional(cs) && sym == ds) {
916 if ((sym->type == S_BOOLEAN) &&
917 sym_get_tristate_value(sym) == yes)
918 goto next_menu;
919 }
920 }
921 print_symbol_for_dotconfig(out, sym);
922 }
923next_menu:
924 if (menu->list != NULL) {
925 menu = menu->list;
926 }

Callers 1

mainFunction · 0.85

Calls 15

fopenFunction · 0.85
sym_clear_all_validFunction · 0.85
menu_is_visibleFunction · 0.85
sym_is_choiceFunction · 0.85
sym_calc_valueFunction · 0.85
sym_is_changeableFunction · 0.85
sym_get_string_valueFunction · 0.85
sym_get_string_defaultFunction · 0.85
sym_is_choice_valueFunction · 0.85
prop_get_symbolFunction · 0.85
sym_get_choice_propFunction · 0.85
sym_choice_defaultFunction · 0.85

Tested by

no test coverage detected