From dba7dd5a44ca00b230c5af55c5cc0f960d299a99 Mon Sep 17 00:00:00 2001 From: "Luiz Fernando N. Capitulino" Date: Wed, 4 Feb 2009 02:19:12 -0500 Subject: [PATCH] depmod: Allow empty modules.dep file creation Commit c0aa5cd6b7c24345ba39a0082989b784d5d0d24a fixed the file truncation bug but also introduced a new problem: it doesn't allow the creation of an empty modules.dep file. The right fix is to only forbid the truncation when modules have been specified in the command-line. Thanks to Alan Jenkins for noticing this. Signed-off-by: Luiz Fernando N. Capitulino Signed-off-by: Jon Masters --- depmod.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/depmod.c b/depmod.c index d8b8f29..60eb0a1 100644 --- a/depmod.c +++ b/depmod.c @@ -1382,10 +1382,12 @@ int main(int argc, char *argv[]) /* Do command line args. */ for (opt = optind; opt < argc; opt++) { struct module *new = grab_module(NULL, argv[opt]); - if (new) { - new->next = list; - list = new; + if (!new) { + /* cmd-line specified modules must exist */ + fatal("grab_module() failed for module %s\n", argv[opt]); } + new->next = list; + list = new; } } else { list = grab_basedir(dirname,search,overrides); @@ -1393,11 +1395,6 @@ int main(int argc, char *argv[]) list = sort_modules(dirname,list); list = parse_modules(list); - if (!list) { - /* Do nothing if nothing has been found */ - fatal("No modules have been found, exiting\n"); - } - for (i = 0; i < sizeof(depfiles)/sizeof(depfiles[0]); i++) { FILE *out; struct depfile *d = &depfiles[i]; -- 2.11.4.GIT