scripts/kconfig/conf.c

Source file repositories/reference/linux-study-clean/scripts/kconfig/conf.c

File Facts

System
Linux kernel
Corpus path
scripts/kconfig/conf.c
Extension
.c
Size
18913 bytes
Lines
868
Domain
Support Tooling And Documentation
Bucket
scripts
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

menu_for_each_sub_entry(menu, choice) {
			struct symbol *sym = menu->sym;

			if (sym && !sym_has_value(sym))
				x--;

			if (x < 0) {
				sym->def[S_DEF_USER].tri = yes;
				sym->flags |= SYMBOL_DEF_USER;
				/*
				 * Move the selected item to the _tail_ because
				 * this needs to have a lower priority than the
				 * user input from KCONFIG_ALLCONFIG.
				 */
				list_move_tail(&sym->choice_link,
					       &choice->choice_members);

				break;
			}
		}
		cnt--;
	}
}

enum conf_def_mode {
	def_default,
	def_yes,
	def_mod,
	def_no,
	def_random
};

static void conf_set_all_new_symbols(enum conf_def_mode mode)
{
	struct menu *menu;
	int cnt;
	/*
	 * can't go as the default in switch-case below, otherwise gcc whines
	 * about -Wmaybe-uninitialized
	 */
	int pby = 50; /* probability of bool     = y */
	int pty = 33; /* probability of tristate = y */
	int ptm = 33; /* probability of tristate = m */

	if (mode == def_random) {
		int n, p[3];
		char *env = getenv("KCONFIG_PROBABILITY");

		n = 0;
		while (env && *env) {
			char *endp;
			int tmp = strtol(env, &endp, 10);

			if (tmp >= 0 && tmp <= 100) {
				p[n++] = tmp;
			} else {
				errno = ERANGE;
				perror("KCONFIG_PROBABILITY");
				exit(1);
			}
			env = (*endp == ':') ? endp + 1 : endp;
			if (n >= 3)
				break;
		}
		switch (n) {
		case 1:
			pby = p[0];
			ptm = pby / 2;
			pty = pby - ptm;
			break;
		case 2:
			pty = p[0];
			ptm = p[1];
			pby = pty + ptm;
			break;
		case 3:
			pby = p[0];
			pty = p[1];
			ptm = p[2];
			break;
		}

		if (pty + ptm > 100) {
			errno = ERANGE;
			perror("KCONFIG_PROBABILITY");
			exit(1);
		}
	}

	menu_for_each_entry(menu) {

Annotation

Implementation Notes