Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kconfig: remove compat_getline()

Commit 1a7a8c6fd8ca ("kconfig: allow long lines in config file") added
a self-implemented getline() for better portability.

However, getline() is standardized [1] and already used in other programs
such as scripts/kallsyms.c.

Use getline() provided by libc.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+1 -52
+1 -52
scripts/kconfig/confdata.c
··· 293 293 return 0; 294 294 } 295 295 296 - #define LINE_GROWTH 16 297 - static int add_byte(int c, char **lineptr, size_t slen, size_t *n) 298 - { 299 - size_t new_size = slen + 1; 300 - 301 - if (new_size > *n) { 302 - new_size += LINE_GROWTH - 1; 303 - new_size *= 2; 304 - *lineptr = xrealloc(*lineptr, new_size); 305 - *n = new_size; 306 - } 307 - 308 - (*lineptr)[slen] = c; 309 - 310 - return 0; 311 - } 312 - 313 - static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream) 314 - { 315 - char *line = *lineptr; 316 - size_t slen = 0; 317 - 318 - for (;;) { 319 - int c = getc(stream); 320 - 321 - switch (c) { 322 - case '\n': 323 - if (add_byte(c, &line, slen, n) < 0) 324 - goto e_out; 325 - slen++; 326 - /* fall through */ 327 - case EOF: 328 - if (add_byte('\0', &line, slen, n) < 0) 329 - goto e_out; 330 - *lineptr = line; 331 - if (slen == 0) 332 - return -1; 333 - return slen; 334 - default: 335 - if (add_byte(c, &line, slen, n) < 0) 336 - goto e_out; 337 - slen++; 338 - } 339 - } 340 - 341 - e_out: 342 - line[slen-1] = '\0'; 343 - *lineptr = line; 344 - return -1; 345 - } 346 - 347 296 /* like getline(), but the newline character is stripped away */ 348 297 static ssize_t getline_stripped(char **lineptr, size_t *n, FILE *stream) 349 298 { 350 299 ssize_t len; 351 300 352 - len = compat_getline(lineptr, n, stream); 301 + len = getline(lineptr, n, stream); 353 302 354 303 if (len > 0 && (*lineptr)[len - 1] == '\n') { 355 304 len--;