From 6da787a5cc94d1b20d0730c18905ff3b93201874 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Tue, 8 May 2012 20:24:48 +0200 Subject: Declare several parameters/variables constant Add the "const" keyword to parameters and variables that are never modified. Most of these were spotted by "-Wwrite-strings". We cast the second parameter to execvp() explicitly as it expects a "char *const[]" where it should expect a "const char *const[]" (according to the documentation, this is due to compatibility reasons). This should be changed once we come up with a better solution. Signed-off-by: Lukas Fleischer --- src/args.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/args.c') diff --git a/src/args.c b/src/args.c index b861018..1a4b38c 100644 --- a/src/args.c +++ b/src/args.c @@ -480,8 +480,9 @@ display_app (struct tm *t, int numdays, int add_line, const char *fmt_apt, * days. */ static void -date_arg (char *ddate, int add_line, const char *fmt_apt, const char *fmt_rapt, - const char *fmt_ev, const char *fmt_rev, regex_t *regex) +date_arg (const char *ddate, int add_line, const char *fmt_apt, + const char *fmt_rapt, const char *fmt_ev, const char *fmt_rev, + regex_t *regex) { int i; struct date day; @@ -544,7 +545,7 @@ date_arg (char *ddate, int add_line, const char *fmt_apt, const char *fmt_rapt, * Many thanks to Erik Saule for providing this function. */ static void -date_arg_extended (char *startday, char *range, int add_line, +date_arg_extended (const char *startday, const char *range, int add_line, const char *fmt_apt, const char *fmt_rapt, const char *fmt_ev, const char *fmt_rev, regex_t *regex) { @@ -633,8 +634,8 @@ parse_args (int argc, char **argv) const char *fmt_todo = "%p. %m\n"; int tnum = 0, xfmt = 0, non_interactive = 0, multiple_flag = 0, load_data = 0; - char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL; - char *datadir = NULL, *ifile = NULL; + const char *ddate = "", *cfile = NULL, *range = NULL, *startday = NULL; + const char *datadir = NULL, *ifile = NULL; regex_t reg, *preg = NULL; /* Long options only */ @@ -644,7 +645,7 @@ parse_args (int argc, char **argv) STATUS_OPT = CHAR_MAX + 1 }; - static char *optstr = "ghvnNax::t::d:c:r::s::S:D:i:"; + static const char *optstr = "ghvnNax::t::d:c:r::s::S:D:i:"; struct option longopts[] = { {"appointment", no_argument, NULL, 'a'}, -- cgit v1.2.3-54-g00ecf