summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <Jiri Olsa jolsa@redhat.com>2011-05-30 20:33:43 +0200
committerJiri Olsa <Jiri Olsa jolsa@redhat.com>2011-05-30 20:33:43 +0200
commitbb2eef443e3e8ecf1ec00c135ce40c5d2dca23cf (patch)
treec0a753afa7c8acd9a242dd11183673cdde6b26c8
parent481bb4e02903a0023ed0c15bb87711479642cc8c (diff)
downloadlatrace-bb2eef443e3e8ecf1ec00c135ce40c5d2dca23cf.tar.gz
latrace-bb2eef443e3e8ecf1ec00c135ce40c5d2dca23cf.tar.xz
latrace-bb2eef443e3e8ecf1ec00c135ce40c5d2dca23cf.zip
reading the -N config file immediatelly within args processing
it makes more sense to read the -N config file immediatelly within the arguments processing, since more confing files can be added
-rw-r--r--ChangeLog2
-rw-r--r--src/config.c22
2 files changed, 10 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index bfd0ba9..c66e307 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
2011-05-30 Jiri Olsa <olsajiri@gmail.com>
* fixed bug in tracer waiting code
(do not exit the loop prematurely)
+ * reading the -N config file immediatelly within
+ args processing
2011-05-25 Jiri Olsa <olsajiri@gmail.com>
* adding SIGTERM/SIGINT handlers,
diff --git a/src/config.c b/src/config.c
index cef8e41..df78c10 100644
--- a/src/config.c
+++ b/src/config.c
@@ -131,7 +131,7 @@ static int read_config(struct lt_config_app *cfg, char *file)
int ret = 0;
lt_config_parse_init(cfg, &inc);
- PRINT_VERBOSE(cfg, 1, "arguments definition file %s\n", file);
+ PRINT_VERBOSE(cfg, 1, "config file %s\n", file);
if (lt_inc_open(cfg->sh, &inc, file))
return -1;
@@ -327,8 +327,6 @@ struct lt_config_opt *lt_config_opt_new(int idx, char *sval, long nval)
int lt_config(struct lt_config_app *cfg, int argc, char **argv)
{
- char *conf_file = LT_CONF_DIR "/latrace.conf";
-
memset(cfg, 0, sizeof(*cfg));
cfg->sh = cfg->sh_storage.sh = &cfg->sh_storage;
@@ -345,13 +343,11 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv)
cfg->output_tty_fd = -1;
/* read the default config file first */
- if (read_config(cfg, conf_file)) {
- printf("failed: read config file '%s'\n", conf_file);
+ if (read_config(cfg, LT_CONF_DIR "/latrace.conf")) {
+ printf("failed: read config file '" LT_CONF_DIR "/latrace.conf'\n");
usage();
}
- conf_file = NULL;
-
while (1) {
int c;
int option_index = 0;
@@ -528,7 +524,11 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv)
#endif /* CONFIG_ARCH_HAVE_ARGS */
case 'N':
- conf_file = optarg;
+ /* read user-specifide config file */
+ if (read_config(cfg, optarg)) {
+ printf("failed: read config file '%s'\n", optarg);
+ usage();
+ }
break;
case 'o':
@@ -567,12 +567,6 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv)
cfg->arg_num = i_arg;
}
- /* read user-specifide config file */
- if (conf_file && read_config(cfg, conf_file)) {
- printf("failed: read config file '%s'\n", conf_file);
- usage();
- }
-
if (!cfg->prog) {
printf("failed: no program specified\n");
usage();