summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-01-03 02:13:29 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-01-03 23:06:16 +0100
commite3e4dd2146df1d24887de3106c2b3cc4b44a5fb1 (patch)
treefc5a3a7fc7ee3c94207a9ac22c542fa97bbae693
parentfcc722a02eecc697ad8c7058853a40aeccab2a1a (diff)
downloadratpoison-e3e4dd2146df1d24887de3106c2b3cc4b44a5fb1.zip
Better error checking for -f configfile.
* make read_startup_files() return whether it succeeded. A failure is when the user passed a specific config file, but we couldn't load it. * in main() exit if read_startup_files() failed.
-rw-r--r--src/main.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main.c b/src/main.c
index 7a4a008..111b591 100644
--- a/src/main.c
+++ b/src/main.c
@@ -402,7 +402,7 @@ read_rc_file (FILE *file)
free (line);
}
-static void
+static int
read_startup_files (char *alt_rcfile)
{
char *homedir;
@@ -412,8 +412,9 @@ read_startup_files (char *alt_rcfile)
{
if ((fileptr = fopen (alt_rcfile, "r")) == NULL)
{
- /* we probably don't need to report this, its not an error */
- PRINT_DEBUG (("ratpoison: could not open %s\n", alt_rcfile));
+ PRINT_ERROR (("ratpoison: could not open %s (%s)\n", alt_rcfile,
+ strerror (errno)));
+ return -1;
}
}
else
@@ -452,6 +453,7 @@ read_startup_files (char *alt_rcfile)
read_rc_file (fileptr);
fclose (fileptr);
}
+ return 0;
}
/* Odd that we spend so much code on making sure the silly welcome
@@ -746,9 +748,9 @@ main (int argc, char *argv[])
}
}
- read_startup_files (alt_rcfile);
- if (alt_rcfile)
- free (alt_rcfile);
+ if (read_startup_files (alt_rcfile) == -1)
+ return EXIT_FAILURE;
+ free (alt_rcfile);
/* Indicate to the user that ratpoison has booted. */
if (defaults.startup_message)