diff mbox

kconfig: allow long lines in config file

Message ID 1341964078-22594-1-git-send-email-cody@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

cody@linux.vnet.ibm.com July 10, 2012, 11:47 p.m. UTC
From: Cody Schafer <cody@linux.vnet.ibm.com>

For some config options (CONFIG_EXTRA_FIRMWARE, for example), the length
of a config file line can exceed the 1024 byte buffer.

Switch from fgets to getline to fix.

Signed-off-by: Cody Schafer <cody@linux.vnet.ibm.com>
---
 scripts/kconfig/confdata.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Michal Marek July 13, 2012, 1:07 p.m. UTC | #1
On 11.7.2012 01:47, cody@linux.vnet.ibm.com wrote:
> From: Cody Schafer <cody@linux.vnet.ibm.com>
> 
> For some config options (CONFIG_EXTRA_FIRMWARE, for example), the length
> of a config file line can exceed the 1024 byte buffer.
> 
> Switch from fgets to getline to fix.

getline() is not a portable function and kconfig is an essential part of
kernel build. Could you please change it to a loop over fgets that
terminates when the last character is '\n'?

Thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
cody@linux.vnet.ibm.com July 13, 2012, 6:30 p.m. UTC | #2
Do we have any strict standards for what is and is not portable?

(I'm aware 'getline' was only added to posix ~4 years ago in 2008).

--
Cody

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek July 13, 2012, 8:39 p.m. UTC | #3
Dne 13.7.2012 20:30, cody napsal(a):
> Do we have any strict standards for what is and is not portable?

We don't. I only checked the existing userspace code and except for
perf, there is no other usage of getline().


> (I'm aware 'getline' was only added to posix ~4 years ago in 2008).

Ah, good to know. Nevetheless, let's stay conservative for some more
time. Thanks for sending the updated patch, btw.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 52577f0..175037f 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -185,7 +185,8 @@  static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
 int conf_read_simple(const char *name, int def)
 {
 	FILE *in = NULL;
-	char line[1024];
+	char   *line = NULL;
+	size_t  line_asize = 0;
 	char *p, *p2;
 	struct symbol *sym;
 	int i, def_flags;
@@ -247,7 +248,7 @@  load:
 		}
 	}
 
-	while (fgets(line, sizeof(line), in)) {
+	while (getline(&line, &line_asize, in) != -1) {
 		conf_lineno++;
 		sym = NULL;
 		if (line[0] == '#') {
@@ -335,6 +336,7 @@  setsym:
 			cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
 		}
 	}
+	free(line);
 	fclose(in);
 
 	if (modules_sym)