[libvirt] [PATCH] Remove _PATH_DEVNULL usage

# HG changeset patch # User john.levon@sun.com # Date 1229367890 28800 # Node ID c324c231c6a50be9f970f0f6c6d1629a7c09ab3b # Parent 63174fd9f33749cb68431fd5d1ff6133ba48863b Remove _PATH_DEVNULL usage _PATH_DEVNULL provides no apparent advantage, and isn't available on Solaris: replace with the string literal. Signed-off-by: John Levon <john.levon@sun.com> diff --git a/qemud/qemud.c b/qemud/qemud.c --- a/qemud/qemud.c +++ b/qemud/qemud.c @@ -397,9 +397,9 @@ static int qemudGoDaemon(void) { int stdoutfd = -1; int nextpid; - if ((stdinfd = open(_PATH_DEVNULL, O_RDONLY)) < 0) + if ((stdinfd = open("/dev/null", O_RDONLY)) < 0) goto cleanup; - if ((stdoutfd = open(_PATH_DEVNULL, O_WRONLY)) < 0) + if ((stdoutfd = open("/dev/null", O_WRONLY)) < 0) goto cleanup; if (dup2(stdinfd, STDIN_FILENO) != STDIN_FILENO) goto cleanup; diff --git a/src/util.c b/src/util.c --- a/src/util.c +++ b/src/util.c @@ -205,10 +205,10 @@ __virExec(virConnectPtr conn, return -1; } - if ((null = open(_PATH_DEVNULL, O_RDONLY)) < 0) { + if ((null = open("/dev/null", O_RDONLY)) < 0) { ReportError(conn, VIR_ERR_INTERNAL_ERROR, _("cannot open %s: %s"), - _PATH_DEVNULL, strerror(errno)); + "/dev/null", strerror(errno)); goto cleanup; } diff --git a/tests/testutils.c b/tests/testutils.c --- a/tests/testutils.c +++ b/tests/testutils.c @@ -35,10 +35,6 @@ #ifdef HAVE_PATHS_H #include <paths.h> -#endif - -#ifndef _PATH_DEVNULL -#define _PATH_DEVNULL "/dev/null" #endif #define GETTIMEOFDAY(T) gettimeofday(T, NULL) @@ -157,9 +153,9 @@ void virtTestCaptureProgramExecChild(con NULL }; - if ((stdinfd = open(_PATH_DEVNULL, O_RDONLY)) < 0) - goto cleanup; - if ((stderrfd = open(_PATH_DEVNULL, O_WRONLY)) < 0) + if ((stdinfd = open("/dev/null", O_RDONLY)) < 0) + goto cleanup; + if ((stderrfd = open("/dev/null", O_WRONLY)) < 0) goto cleanup; open_max = sysconf (_SC_OPEN_MAX);

On Mon, Dec 15, 2008 at 11:57:52AM -0800, john.levon@sun.com wrote:
# HG changeset patch # User john.levon@sun.com # Date 1229367890 28800 # Node ID c324c231c6a50be9f970f0f6c6d1629a7c09ab3b # Parent 63174fd9f33749cb68431fd5d1ff6133ba48863b Remove _PATH_DEVNULL usage
_PATH_DEVNULL provides no apparent advantage, and isn't available on Solaris: replace with the string literal.
ACK, I just happened to use _PATH_DEVNULL because I saw it was available & didn't check its portability. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
john.levon@sun.com