oldfind: fix compiler warnings

Avoid the following 2 warnings:

oldfind.c: In function ‘main’:
oldfind.c:228:5: warning: passing argument 1 of ‘ctime’ from incompatible pointer type [enabled by default]
     fprintf (stderr, "cur_day_start = %s", ctime (&options.cur_day_start/*.tv_sec*/));
     ^
In file included from ../gl/lib/time.h:41:0,
                 from ../gl/lib/sys/stat.h:44,
                 from oldfind.c:35:
/usr/include/time.h:264:14: note: expected ‘const time_t *’ but argument is of type ‘struct timespec *’
oldfind.c: In function ‘at_top’:
oldfind.c:1003:12: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
       base = pathname;
            ^

* find/oldfind.c (main): Correct the call to ctime; it takes time_t*,
so don't pass struct timeval*; instead, pass the address of the tv_sec
member.
(at_top): Declare base as const char*.
This commit is contained in:
Bernhard Voelker 2016-11-01 17:29:44 +01:00
parent f704697121
commit 7b6fd7b68b

View File

@ -225,7 +225,7 @@ main (int argc, char **argv)
options.xstat = debug_stat;
if (options.debug_options & DebugTime)
fprintf (stderr, "cur_day_start = %s", ctime (&options.cur_day_start));
fprintf (stderr, "cur_day_start = %s", ctime (&options.cur_day_start.tv_sec));
/* state.cwd_dir_fd has to be initialized before we call build_expression_tree ()
* because command-line parsing may lead us to stat some files.
@ -991,7 +991,7 @@ at_top (const char *pathname,
{
int dirchange;
char *parent_dir = dir_name (pathname);
char *base = last_component (pathname);
const char *base = last_component (pathname);
state.curdepth = 0;
state.starting_path_length = strlen (pathname);