Commit 01b5cbe
committed
fixdep: use malloc() and read() to load dep_file to buffer
Commit dee81e9 ("fixdep: faster CONFIG_ search") changed how to
read files in which CONFIG options are searched. It used malloc()
and read() instead of mmap() because it needed to zero-terminate the
buffer in order to use strstr(). print_deps() was left untouched
since there was no reason to change it.
Now, I have two motivations to change it in the same way.
- do_config_file() and print_deps() do quite similar things; they
open a file, load it onto memory, and pass it to a parser function.
If we use malloc() and read() for print_deps() too, we can factor
out the common code. (I will do this in the next commit.)
- parse_dep_file() copies each token to a temporary buffer because
it needs to zero-terminate it to be passed to printf(). It is not
possible to modify the buffer directly because it is mmap'ed with
O_RDONLY. If we load the file content into a malloc'ed buffer, we
can insert '\0' after each token, and save memcpy(). (I will do
this in the commit after next.)
Signed-off-by: Masahiro Yamada <[email protected]>1 parent 41f92cf commit 01b5cbe
1 file changed
Lines changed: 32 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
| |||
308 | 307 | | |
309 | 308 | | |
310 | 309 | | |
311 | | - | |
| 310 | + | |
312 | 311 | | |
313 | | - | |
314 | | - | |
315 | 312 | | |
316 | 313 | | |
317 | | - | |
| 314 | + | |
318 | 315 | | |
319 | 316 | | |
320 | 317 | | |
321 | | - | |
| 318 | + | |
322 | 319 | | |
323 | | - | |
| 320 | + | |
324 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
325 | 326 | | |
326 | 327 | | |
327 | | - | |
| 328 | + | |
328 | 329 | | |
| 330 | + | |
329 | 331 | | |
330 | 332 | | |
331 | 333 | | |
| |||
373 | 375 | | |
374 | 376 | | |
375 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
376 | 382 | | |
377 | 383 | | |
378 | 384 | | |
| |||
391 | 397 | | |
392 | 398 | | |
393 | 399 | | |
394 | | - | |
| 400 | + | |
395 | 401 | | |
396 | 402 | | |
397 | 403 | | |
398 | | - | |
| 404 | + | |
399 | 405 | | |
400 | | - | |
| 406 | + | |
401 | 407 | | |
402 | 408 | | |
403 | | - | |
| 409 | + | |
404 | 410 | | |
405 | 411 | | |
406 | 412 | | |
407 | 413 | | |
408 | | - | |
| 414 | + | |
409 | 415 | | |
410 | 416 | | |
411 | 417 | | |
412 | | - | |
413 | 418 | | |
414 | 419 | | |
415 | 420 | | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
421 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
422 | 432 | | |
423 | | - | |
424 | | - | |
425 | | - | |
| 433 | + | |
426 | 434 | | |
427 | | - | |
| 435 | + | |
428 | 436 | | |
429 | 437 | | |
430 | 438 | | |
| |||
440 | 448 | | |
441 | 449 | | |
442 | 450 | | |
443 | | - | |
| 451 | + | |
444 | 452 | | |
445 | 453 | | |
446 | 454 | | |
0 commit comments