From d0fe11d76c6ffc15b81273d7ae12718d5b37c7d7 Mon Sep 17 00:00:00 2001 From: Jan Cermak Date: Tue, 11 Dec 2012 17:41:49 -0500 Subject: [PATCH] Added const to char* function arguments where appropriate --- lib/append.c | 4 ++-- lib/encode.c | 4 ++-- lib/handle.c | 6 +++--- lib/libtar.h | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/append.c b/lib/append.c index 05024b9..13e1ace 100644 --- a/lib/append.c +++ b/lib/append.c @@ -54,7 +54,7 @@ tar_dev_free(tar_dev_t *tdp) /* appends a file to the tar archive */ int -tar_append_file(TAR *t, char *realname, char *savename) +tar_append_file(TAR *t, const char *realname, const char *savename) { struct stat s; int i; @@ -208,7 +208,7 @@ tar_append_eof(TAR *t) /* add file contents to a tarchive */ int -tar_append_regfile(TAR *t, char *realname) +tar_append_regfile(TAR *t, const char *realname) { char block[T_BLOCKSIZE]; int filefd; diff --git a/lib/encode.c b/lib/encode.c index 662eff5..5ea29ff 100644 --- a/lib/encode.c +++ b/lib/encode.c @@ -68,7 +68,7 @@ th_set_type(TAR *t, mode_t mode) /* encode file path */ void -th_set_path(TAR *t, char *pathname) +th_set_path(TAR *t, const char *pathname) { char suffix[2] = ""; char *tmp; @@ -116,7 +116,7 @@ th_set_path(TAR *t, char *pathname) /* encode link path */ void -th_set_link(TAR *t, char *linkname) +th_set_link(TAR *t, const char *linkname) { #ifdef DEBUG printf("==> th_set_link(th, linkname=\"%s\")\n", linkname); diff --git a/lib/handle.c b/lib/handle.c index ae974b9..33a262c 100644 --- a/lib/handle.c +++ b/lib/handle.c @@ -31,7 +31,7 @@ static tartype_t default_type = { open, close, read, write }; static int -tar_init(TAR **t, char *pathname, tartype_t *type, +tar_init(TAR **t, const char *pathname, tartype_t *type, int oflags, int mode, int options) { if ((oflags & O_ACCMODE) == O_RDWR) @@ -66,7 +66,7 @@ tar_init(TAR **t, char *pathname, tartype_t *type, /* open a new tarfile handle */ int -tar_open(TAR **t, char *pathname, tartype_t *type, +tar_open(TAR **t, const char *pathname, tartype_t *type, int oflags, int mode, int options) { if (tar_init(t, pathname, type, oflags, mode, options) == -1) @@ -91,7 +91,7 @@ tar_open(TAR **t, char *pathname, tartype_t *type, int -tar_fdopen(TAR **t, int fd, char *pathname, tartype_t *type, +tar_fdopen(TAR **t, int fd, const char *pathname, tartype_t *type, int oflags, int mode, int options) { if (tar_init(t, pathname, type, oflags, mode, options) == -1) diff --git a/lib/libtar.h b/lib/libtar.h index b29cf7a..55f509a 100644 --- a/lib/libtar.h +++ b/lib/libtar.h @@ -104,11 +104,11 @@ extern const char libtar_version[]; /* open a new tarfile handle */ -int tar_open(TAR **t, char *pathname, tartype_t *type, +int tar_open(TAR **t, const char *pathname, tartype_t *type, int oflags, int mode, int options); /* make a tarfile handle out of a previously-opened descriptor */ -int tar_fdopen(TAR **t, int fd, char *pathname, tartype_t *type, +int tar_fdopen(TAR **t, int fd, const char *pathname, tartype_t *type, int oflags, int mode, int options); /* returns the descriptor associated with t */ @@ -132,13 +132,13 @@ void tar_dev_free(struct tar_dev *tdp); * realname = path of file to append * savename = name to save the file under in the archive */ -int tar_append_file(TAR *t, char *realname, char *savename); +int tar_append_file(TAR *t, const char *realname, const char *savename); /* write EOF indicator */ int tar_append_eof(TAR *t); /* add file contents to a tarchive */ -int tar_append_regfile(TAR *t, char *realname); +int tar_append_regfile(TAR *t, const char *realname); /***** block.c *************************************************************/ @@ -197,8 +197,8 @@ gid_t th_get_gid(TAR *t); /* encode file info in th_header */ void th_set_type(TAR *t, mode_t mode); -void th_set_path(TAR *t, char *pathname); -void th_set_link(TAR *t, char *linkname); +void th_set_path(TAR *t, const char *pathname); +void th_set_link(TAR *t, const char *linkname); void th_set_device(TAR *t, dev_t device); void th_set_user(TAR *t, uid_t uid); void th_set_group(TAR *t, gid_t gid); -- 2.11.4.GIT