diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-07-17 13:31:05 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-08-05 21:15:52 +0100 |
commit | d8803be5c2ec7deae728a0955298c4af8f37a890 (patch) | |
tree | 90f0c7d00afbb55e4c0c27dbab88d8303ec760cd /daemon | |
parent | eb694a0a0a5b46d3112c680c41884fb0aab0061d (diff) | |
download | libguestfs-d8803be5c2ec7deae728a0955298c4af8f37a890.tar.gz libguestfs-d8803be5c2ec7deae728a0955298c4af8f37a890.tar.xz libguestfs-d8803be5c2ec7deae728a0955298c4af8f37a890.zip |
case_sensitive_path: Move variables to top of function.
This is just code motion.
(cherry picked from commit ac0373bdecfabe6acf99d3662e5117de73fa2aef)
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/realpath.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/daemon/realpath.c b/daemon/realpath.c index 2d657a4c..edf6da0a 100644 --- a/daemon/realpath.c +++ b/daemon/realpath.c @@ -84,8 +84,11 @@ char * do_case_sensitive_path (const char *path) { char ret[PATH_MAX+1] = "/"; + char name[NAME_MAX+1]; size_t next = 1; - int fd_cwd; + int fd_cwd, fd2, err; + size_t i; + char *retp; /* 'fd_cwd' here is a surrogate for the current working directory, so * that we don't have to actually call chdir(2). @@ -100,7 +103,7 @@ do_case_sensitive_path (const char *path) * and follow it. */ while (*path) { - size_t i = strcspn (path, "/"); + i = strcspn (path, "/"); if (i == 0) { path++; continue; @@ -116,7 +119,6 @@ do_case_sensitive_path (const char *path) goto error; } - char name[NAME_MAX+1]; memcpy (name, path, i); name[i] = '\0'; @@ -143,8 +145,8 @@ do_case_sensitive_path (const char *path) next += i; /* Is it a directory? Try going into it. */ - int fd2 = openat (fd_cwd, name, O_RDONLY|O_DIRECTORY|O_CLOEXEC); - int err = errno; + fd2 = openat (fd_cwd, name, O_RDONLY|O_DIRECTORY|O_CLOEXEC); + err = errno; close (fd_cwd); fd_cwd = fd2; errno = err; @@ -166,7 +168,7 @@ do_case_sensitive_path (const char *path) close (fd_cwd); ret[next] = '\0'; - char *retp = strdup (ret); + retp = strdup (ret); if (retp == NULL) { reply_with_perror ("strdup"); return NULL; |