[PATCH] daemon/file.c: remove duplicate absolute-path check
minor clean-up:
From cac2ce53aec6d3aaca83e4bbc3551d452c29c0b2 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Fri, 7 Aug 2009 20:07:03 +0200 Subject: [PATCH] daemon/file.c: remove duplicate absolute-path check
* daemon/file.c (do_file): Remove redundant use of ABS_PATH. It's redundant because the preceding line invokes NEED_ROOT_OR_IS_DEVICE, which also invokes ABS_PATH. --- daemon/file.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/daemon/file.c b/daemon/file.c index 63d8dd2..cd477e5 100644 --- a/daemon/file.c +++ b/daemon/file.c @@ -392,7 +392,6 @@ do_file (char *path) int len; NEED_ROOT_OR_IS_DEVICE (path, NULL); - ABS_PATH (path, NULL); if (strncmp (path, "/dev/", 5) == 0) buf = (char *) path; -- 1.6.4.161.gc0b1
On Fri, Aug 07, 2009 at 08:07:50PM +0200, Jim Meyering wrote:
minor clean-up:
From cac2ce53aec6d3aaca83e4bbc3551d452c29c0b2 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Fri, 7 Aug 2009 20:07:03 +0200 Subject: [PATCH] daemon/file.c: remove duplicate absolute-path check
* daemon/file.c (do_file): Remove redundant use of ABS_PATH. It's redundant because the preceding line invokes NEED_ROOT_OR_IS_DEVICE, which also invokes ABS_PATH.
Agreed, ACK. If we had a separate 'Path' type in the generator, then these checks could be automated. That is to say, splitting the existing String variant into String .. | Device .. | Path .. | DeviceOrPath .., where DeviceOrPath is just needed for the couple of functions that wrongly take a string which could be a device or a path ('file' being one of these). Also note that most (all?) paths get rewritten in the non-generated code to prefix them with the content of the sysroot global variable. (See: sysroot, sysroot_path and the %R custom printf spec). This is particularly error-prone and probably another candidate for automation. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Richard W.M. Jones wrote:
On Fri, Aug 07, 2009 at 08:07:50PM +0200, Jim Meyering wrote:
minor clean-up:
From cac2ce53aec6d3aaca83e4bbc3551d452c29c0b2 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Fri, 7 Aug 2009 20:07:03 +0200 Subject: [PATCH] daemon/file.c: remove duplicate absolute-path check
* daemon/file.c (do_file): Remove redundant use of ABS_PATH. It's redundant because the preceding line invokes NEED_ROOT_OR_IS_DEVICE, which also invokes ABS_PATH.
Agreed, ACK.
Pushed.
If we had a separate 'Path' type in the generator, then these checks could be automated.
That is to say, splitting the existing String variant into String .. | Device .. | Path .. | DeviceOrPath .., where DeviceOrPath is just needed for the couple of functions that wrongly take a string which could be a device or a path ('file' being one of these).
Also note that most (all?) paths get rewritten in the non-generated code to prefix them with the content of the sysroot global variable. (See: sysroot, sysroot_path and the %R custom printf spec). This is particularly error-prone and probably another candidate for automation.
Thanks. I'm working on this now.
On Mon, Aug 10, 2009 at 10:50:10AM +0200, Jim Meyering wrote:
Richard W.M. Jones wrote:
Also note that most (all?) paths get rewritten in the non-generated code to prefix them with the content of the sysroot global variable. (See: sysroot, sysroot_path and the %R custom printf spec). This is particularly error-prone and probably another candidate for automation.
Thanks. I'm working on this now.
I had a think about the particular case of 'Path' over the weekend, and I think that would have to turn into two parameters (in the daemon), ie: int do_somecmd (const char *path, const char *sysroot_path) { if (something_with (sysroot_path) == -1) { reply_with_error (path); The reason is that functions use the original path or the prefixed path in various places. Original path for: - error messages - syscalls inside CHROOT_IN/CHROOT_OUT brackets Path prefixed with sysroot for: - anything outside chroot Escaped path (%Q / %R) for: - shell commands (eg. popen, system) Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
participants (2)
-
Jim Meyering -
Richard W.M. Jones