From 7e7b81b73eba0b353ea6d1bfb681620db58f3a1a Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Mon, 5 Sep 2005 00:52:56 +0000 Subject: [PATCH] * direntry.c: Added const qualifiers to work around gcc warnings. * extfs.c: Likewise. * fish.c: Likewise. * ftpfs.c: Likewise. * sfs.c: Likewise. * xdirentry.h: Likewise. --- vfs/ChangeLog | 10 ++++++++++ vfs/direntry.c | 18 +++++++++--------- vfs/extfs.c | 9 +++++---- vfs/fish.c | 14 ++++++++------ vfs/ftpfs.c | 3 ++- vfs/sfs.c | 2 +- vfs/xdirentry.h | 2 +- 7 files changed, 36 insertions(+), 22 deletions(-) diff --git a/vfs/ChangeLog b/vfs/ChangeLog index c5db8f310..384f4eba4 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,3 +1,13 @@ +2005-09-05 Roland Illig + + * direntry.c: Added const qualifiers to work around gcc + warnings. + * extfs.c: Likewise. + * fish.c: Likewise. + * ftpfs.c: Likewise. + * sfs.c: Likewise. + * xdirentry.h: Likewise. + 2005-08-15 Roland Illig * vfs-impl.h (union vfs_dirent): Using the offsetof macro diff --git a/vfs/direntry.c b/vfs/direntry.c index bab237338..7867c0796 100644 --- a/vfs/direntry.c +++ b/vfs/direntry.c @@ -456,10 +456,11 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super) * Dissect the path and create corresponding superblock. Note that inname * can be changed and the result may point inside the original string. */ -char * +const char * vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **archive, int flags) { + const char *retval; char *local, *op; const char *archive_name; int result = -1; @@ -468,8 +469,7 @@ vfs_s_get_path_mangle (struct vfs_class *me, char *inname, archive_name = inname; vfs_split (inname, &local, &op); - if (!local) - local = ""; + retval = (local) ? local : ""; if (MEDATA->archive_check) if (!(cookie = MEDATA->archive_check (me, archive_name, op))) @@ -506,7 +506,7 @@ vfs_s_get_path_mangle (struct vfs_class *me, char *inname, return_success: *archive = super; - return local; + return retval; } @@ -518,12 +518,12 @@ static char * vfs_s_get_path (struct vfs_class *me, const char *inname, struct vfs_s_super **archive, int flags) { - char * const buf = g_strdup (inname); - char *res = vfs_s_get_path_mangle (me, buf, archive, flags); - if (res) - res = g_strdup (res); + char *buf, *retval; + + buf = g_strdup (inname); + retval = g_strdup (vfs_s_get_path_mangle (me, buf, archive, flags)); g_free (buf); - return res; + return retval; } void diff --git a/vfs/extfs.c b/vfs/extfs.c index f71c7009e..ef6881416 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -155,7 +155,7 @@ static void extfs_make_dots (struct entry *ent) } static struct entry *extfs_generate_entry (struct archive *archive, - char *name, struct entry *parentry, mode_t mode) + const char *name, struct entry *parentry, mode_t mode) { mode_t myumask; struct inode *inode, *parent; @@ -452,7 +452,7 @@ extfs_get_path_mangle (struct vfs_class *me, char *inname, struct archive **arch if (fstype == -1) return NULL; if (!local) - local = ""; + local = inname + strlen (inname); /* * All filesystems should have some local archive, at least @@ -582,9 +582,10 @@ static struct entry *extfs_resolve_symlinks (struct entry *entry) return res; } -static char *extfs_get_archive_name (struct archive *archive) +static const char * +extfs_get_archive_name (struct archive *archive) { - char *archive_name; + const char *archive_name; if (archive->local_name) archive_name = archive->local_name; diff --git a/vfs/fish.c b/vfs/fish.c index 27899dfba..c9116f2b0 100644 --- a/vfs/fish.c +++ b/vfs/fish.c @@ -712,13 +712,14 @@ fish_send_command(struct vfs_class *me, struct vfs_s_super *super, const char *c #define PREFIX \ char buf[BUF_LARGE]; \ + const char *crpath; \ char *rpath, *mpath = g_strdup (path); \ struct vfs_s_super *super; \ - if (!(rpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \ + if (!(crpath = vfs_s_get_path_mangle (me, mpath, &super, 0))) { \ g_free (mpath); \ return -1; \ } \ - rpath = name_quote (rpath, 0); \ + rpath = name_quote (crpath, 0); \ g_free (mpath); #define POSTFIX(flags) \ @@ -741,20 +742,21 @@ fish_chmod (struct vfs_class *me, const char *path, int mode) static int fish_##name (struct vfs_class *me, const char *path1, const char *path2) \ { \ char buf[BUF_LARGE]; \ + const char *crpath1, *crpath2; \ char *rpath1, *rpath2, *mpath1, *mpath2; \ struct vfs_s_super *super1, *super2; \ - if (!(rpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0))) { \ + if (!(crpath1 = vfs_s_get_path_mangle (me, mpath1 = g_strdup(path1), &super1, 0))) { \ g_free (mpath1); \ return -1; \ } \ - if (!(rpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0))) { \ + if (!(crpath2 = vfs_s_get_path_mangle (me, mpath2 = g_strdup(path2), &super2, 0))) { \ g_free (mpath1); \ g_free (mpath2); \ return -1; \ } \ - rpath1 = name_quote (rpath1, 0); \ + rpath1 = name_quote (crpath1, 0); \ g_free (mpath1); \ - rpath2 = name_quote (rpath2, 0); \ + rpath2 = name_quote (crpath2, 0); \ g_free (mpath2); \ g_snprintf(buf, sizeof(buf), string "\n", rpath1, rpath2, rpath1, rpath2); \ g_free (rpath1); \ diff --git a/vfs/ftpfs.c b/vfs/ftpfs.c index 1c3b48969..266e7c986 100644 --- a/vfs/ftpfs.c +++ b/vfs/ftpfs.c @@ -1461,7 +1461,8 @@ static int ftpfs_ctl (void *fh, int ctlop, void *arg) static int ftpfs_send_command(struct vfs_class *me, const char *filename, const char *cmd, int flags) { - char *rpath, *p, *mpath = g_strdup(filename); + const char *rpath; + char *p, *mpath = g_strdup(filename); struct vfs_s_super *super; int r; int flush_directory_cache = (flags & OPT_FLUSH); diff --git a/vfs/sfs.c b/vfs/sfs.c index 6e1d66405..2da364f3b 100644 --- a/vfs/sfs.c +++ b/vfs/sfs.c @@ -148,7 +148,7 @@ sfs_vfmake (struct vfs_class *me, const char *name, char *cache) return 0; /* OK */ } -static char * +static const char * sfs_redirect (struct vfs_class *me, const char *name) { struct cachedfile *cur = head; diff --git a/vfs/xdirentry.h b/vfs/xdirentry.h index 16aceaf2b..599086a1a 100644 --- a/vfs/xdirentry.h +++ b/vfs/xdirentry.h @@ -182,7 +182,7 @@ struct vfs_s_inode *vfs_s_find_root (struct vfs_class *me, /* outside interface */ void vfs_s_init_class (struct vfs_class *vclass, struct vfs_s_subclass *sub); -char *vfs_s_get_path_mangle (struct vfs_class *me, char *inname, +const char *vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **archive, int flags); void vfs_s_invalidate (struct vfs_class *me, struct vfs_s_super *super); char *vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino);