From: Tim Kientzle Date: Sun, 15 Feb 2009 21:46:15 +0000 (-0500) Subject: r625 uncovered a few places where const was needed. X-Git-Tag: v2.7.0~280 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73f713b403e9fbd6bbf64959be1f6c47ac3bbdc2;p=thirdparty%2Flibarchive.git r625 uncovered a few places where const was needed. In particular, the refdir and testprog variables should have been const. SVN-Revision: 626 --- diff --git a/tar/test/main.c b/tar/test/main.c index a2aa08c1d..7bb16f7bc 100644 --- a/tar/test/main.c +++ b/tar/test/main.c @@ -84,7 +84,7 @@ static int skips = 0; static int assertions = 0; /* Directory where uuencoded reference files can be found. */ -static char *refdir; +static const char *refdir; /* * My own implementation of the standard assert() macro emits the @@ -901,10 +901,12 @@ int main(int argc, char **argv) int i, tests_run = 0, tests_failed = 0, opt; time_t now; char *refdir_alloc = NULL; - char *opt_arg, *progname, *p; + const char *opt_arg, *progname, *p; char tmpdir[256]; char tmpdir_timestamp[256]; + (void)argc; /* UNUSED */ + /* * Name of this program, used to build root of our temp directory * tree. @@ -1019,12 +1021,14 @@ int main(int argc, char **argv) * reference files, use the current directory for that. */ if (refdir == NULL) { + char *q; systemf("/bin/pwd > %s/refdir", tmpdir); - refdir = refdir_alloc = slurpfile(NULL, "%s/refdir", tmpdir); - p = refdir + strlen(refdir); - while (p[-1] == '\n') { - --p; - *p = '\0'; + q = slurpfile(NULL, "%s/refdir", tmpdir); + refdir = refdir_alloc = q; + q += strlen(refdir); + while (q[-1] == '\n') { + --q; + *q = '\0'; } systemf("rm %s/refdir", tmpdir); } diff --git a/tar/test/test.h b/tar/test/test.h index f050004ab..3c8c00fa6 100644 --- a/tar/test/test.h +++ b/tar/test/test.h @@ -151,4 +151,4 @@ void extract_reference_file(const char *); */ /* Pathname of exe to be tested. */ -char *testprog; +const char *testprog;