util/kconfig: Uprev to Linux 6.8's kconfig
Linux kconfig has its own implementation of KCONFIG_WERROR now, so use that. This reduces our patch count by 2. Change-Id: I4f5f1f552e96f8ef7a4c5c0ab2ab7e2b6d798ceb Signed-off-by: Patrick Georgi <patrick@georgi.software> Reviewed-on: https://review.coreboot.org/c/coreboot/+/81223 Reviewed-by: Felix Singer <service+coreboot-gerrit@felixsinger.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
committed by
Felix Held
parent
96499840aa
commit
7761237dfe
@@ -155,6 +155,13 @@ static void conf_message(const char *fmt, ...)
|
||||
static const char *conf_filename;
|
||||
static int conf_lineno, conf_warnings;
|
||||
|
||||
bool conf_errors(void)
|
||||
{
|
||||
if (conf_warnings)
|
||||
return getenv("KCONFIG_WERROR");
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#define mkdir(_n,_p) mkdir((_n))
|
||||
#endif
|
||||
@@ -310,16 +317,12 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
#define LINE_GROWTH 16
|
||||
static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
|
||||
{
|
||||
char *nline;
|
||||
size_t new_size = slen + 1;
|
||||
|
||||
if (new_size > *n) {
|
||||
new_size += LINE_GROWTH - 1;
|
||||
new_size *= 2;
|
||||
nline = xrealloc(*lineptr, new_size);
|
||||
if (!nline)
|
||||
return -1;
|
||||
|
||||
*lineptr = nline;
|
||||
*lineptr = xrealloc(*lineptr, new_size);
|
||||
*n = new_size;
|
||||
}
|
||||
|
||||
@@ -362,19 +365,37 @@ e_out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* like getline(), but the newline character is stripped away */
|
||||
static ssize_t getline_stripped(char **lineptr, size_t *n, FILE *stream)
|
||||
{
|
||||
ssize_t len;
|
||||
|
||||
len = compat_getline(lineptr, n, stream);
|
||||
|
||||
if (len > 0 && (*lineptr)[len - 1] == '\n') {
|
||||
len--;
|
||||
(*lineptr)[len] = '\0';
|
||||
|
||||
if (len > 0 && (*lineptr)[len - 1] == '\r') {
|
||||
len--;
|
||||
(*lineptr)[len] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int conf_read_simple(const char *name, int def)
|
||||
{
|
||||
FILE *in = NULL;
|
||||
char *line = NULL;
|
||||
size_t line_asize = 0;
|
||||
char *p, *p2;
|
||||
char *p, *val;
|
||||
struct symbol *sym;
|
||||
int i, def_flags;
|
||||
const char *warn_unknown;
|
||||
const char *werror;
|
||||
const char *warn_unknown, *sym_name;
|
||||
|
||||
warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS");
|
||||
werror = getenv("KCONFIG_WERROR");
|
||||
if (name) {
|
||||
in = zconf_fopen(name);
|
||||
} else {
|
||||
@@ -438,8 +459,7 @@ load:
|
||||
case S_INT:
|
||||
case S_HEX:
|
||||
case S_STRING:
|
||||
if (sym->def[def].val)
|
||||
free(sym->def[def].val);
|
||||
free(sym->def[def].val);
|
||||
/* fall through */
|
||||
default:
|
||||
sym->def[def].val = NULL;
|
||||
@@ -447,90 +467,68 @@ load:
|
||||
}
|
||||
}
|
||||
|
||||
while (compat_getline(&line, &line_asize, in) != -1) {
|
||||
while (getline_stripped(&line, &line_asize, in) != -1) {
|
||||
conf_lineno++;
|
||||
sym = NULL;
|
||||
|
||||
if (!line[0]) /* blank line */
|
||||
continue;
|
||||
|
||||
if (line[0] == '#') {
|
||||
if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
|
||||
if (line[1] != ' ')
|
||||
continue;
|
||||
p = strchr(line + 2 + strlen(CONFIG_), ' ');
|
||||
p = line + 2;
|
||||
if (memcmp(p, CONFIG_, strlen(CONFIG_)))
|
||||
continue;
|
||||
sym_name = p + strlen(CONFIG_);
|
||||
p = strchr(sym_name, ' ');
|
||||
if (!p)
|
||||
continue;
|
||||
*p++ = 0;
|
||||
if (strncmp(p, "is not set", 10))
|
||||
if (strcmp(p, "is not set"))
|
||||
continue;
|
||||
if (def == S_DEF_USER) {
|
||||
sym = sym_find(line + 2 + strlen(CONFIG_));
|
||||
if (!sym) {
|
||||
if (warn_unknown)
|
||||
conf_warning("unknown symbol: %s",
|
||||
line + 2 + strlen(CONFIG_));
|
||||
|
||||
conf_set_changed(true);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
|
||||
if (sym->type == S_UNKNOWN)
|
||||
sym->type = S_BOOLEAN;
|
||||
}
|
||||
if (sym->flags & def_flags) {
|
||||
conf_notice("override: reassigning to symbol %s", sym->name);
|
||||
}
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
sym->def[def].tri = no;
|
||||
sym->flags |= def_flags;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
} else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
|
||||
p = strchr(line + strlen(CONFIG_), '=');
|
||||
if (!p)
|
||||
continue;
|
||||
*p++ = 0;
|
||||
p2 = strchr(p, '\n');
|
||||
if (p2) {
|
||||
*p2-- = 0;
|
||||
if (*p2 == '\r')
|
||||
*p2 = 0;
|
||||
}
|
||||
|
||||
sym = sym_find(line + strlen(CONFIG_));
|
||||
if (!sym) {
|
||||
if (def == S_DEF_AUTO) {
|
||||
/*
|
||||
* Reading from include/config/auto.conf
|
||||
* If CONFIG_FOO previously existed in
|
||||
* auto.conf but it is missing now,
|
||||
* include/config/FOO must be touched.
|
||||
*/
|
||||
conf_touch_dep(line + strlen(CONFIG_));
|
||||
} else {
|
||||
if (warn_unknown)
|
||||
conf_warning("unknown symbol: %s",
|
||||
line + strlen(CONFIG_));
|
||||
|
||||
conf_set_changed(true);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sym->flags & def_flags) {
|
||||
conf_notice("override: reassigning to symbol %s", sym->name);
|
||||
}
|
||||
if (conf_set_sym_val(sym, def, def_flags, p))
|
||||
continue;
|
||||
val = "n";
|
||||
} else {
|
||||
if (line[0] != '\r' && line[0] != '\n')
|
||||
conf_warning("unexpected data: %.*s",
|
||||
(int)strcspn(line, "\r\n"), line);
|
||||
if (memcmp(line, CONFIG_, strlen(CONFIG_))) {
|
||||
conf_warning("unexpected data: %s", line);
|
||||
continue;
|
||||
}
|
||||
|
||||
sym_name = line + strlen(CONFIG_);
|
||||
p = strchr(sym_name, '=');
|
||||
if (!p) {
|
||||
conf_warning("unexpected data: %s", line);
|
||||
continue;
|
||||
}
|
||||
*p = 0;
|
||||
val = p + 1;
|
||||
}
|
||||
|
||||
sym = sym_find(sym_name);
|
||||
if (!sym) {
|
||||
if (def == S_DEF_AUTO) {
|
||||
/*
|
||||
* Reading from include/config/auto.conf.
|
||||
* If CONFIG_FOO previously existed in auto.conf
|
||||
* but it is missing now, include/config/FOO
|
||||
* must be touched.
|
||||
*/
|
||||
conf_touch_dep(sym_name);
|
||||
} else {
|
||||
if (warn_unknown)
|
||||
conf_warning("unknown symbol: %s", sym_name);
|
||||
|
||||
conf_set_changed(true);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sym->flags & def_flags)
|
||||
conf_notice("override: reassigning to symbol %s", sym->name);
|
||||
|
||||
if (conf_set_sym_val(sym, def, def_flags, val))
|
||||
continue;
|
||||
|
||||
if (sym && sym_is_choice_value(sym)) {
|
||||
struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
|
||||
switch (sym->def[def].tri) {
|
||||
@@ -554,11 +552,6 @@ load:
|
||||
free(line);
|
||||
fclose(in);
|
||||
|
||||
if (conf_warnings && werror) {
|
||||
fprintf(stderr, "\nERROR: %d warnings encountered, and warnings are errors.\n\n", conf_warnings);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -617,7 +610,7 @@ int conf_read(const char *name)
|
||||
/* Reset a string value if it's out of range */
|
||||
if (sym_string_within_range(sym, sym->def[S_DEF_USER].val))
|
||||
break;
|
||||
sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER);
|
||||
sym->flags &= ~SYMBOL_VALID;
|
||||
conf_unsaved++;
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user