summaryrefslogtreecommitdiff
path: root/threadproc
diff options
context:
space:
mode:
authorsf <sf@13f79535-47bb-0310-9956-ffa450edef68>2010-07-27 22:09:45 +0000
committersf <sf@13f79535-47bb-0310-9956-ffa450edef68>2010-07-27 22:09:45 +0000
commitb5e9e77c5cd1eaeea59c6398db1f24543c2aff25 (patch)
tree1cb6ddc24a0845e85f254eec9056103e26b73d0b /threadproc
parent6eafa4d6e7416c27216357c24d238081b719186a (diff)
downloadlibapr-b5e9e77c5cd1eaeea59c6398db1f24543c2aff25.tar.gz
Fix various issues found by cppcheck
- error handling issues - use of uninitialized data - null pointer dereference - unused variables - memory/fd leaks - broken code in threadproc/beos/proc.c git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@979891 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc')
-rw-r--r--threadproc/beos/proc.c7
-rw-r--r--threadproc/unix/proc.c7
-rw-r--r--threadproc/unix/procsup.c4
3 files changed, 9 insertions, 9 deletions
diff --git a/threadproc/beos/proc.c b/threadproc/beos/proc.c
index 3092f4502..e3698082f 100644
--- a/threadproc/beos/proc.c
+++ b/threadproc/beos/proc.c
@@ -362,8 +362,9 @@ APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_fi
== APR_SUCCESS)
rv = apr_file_inherit_set(attr->child_in);
}
+ }
- if (parent_in != NULL && rv == APR_SUCCESS) {
+ if (parent_in != NULL && rv == APR_SUCCESS)
rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool);
return rv;
@@ -391,7 +392,7 @@ APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_f
}
}
- if (parent_out != NULL && rv == APR_SUCCESS) {
+ if (parent_out != NULL && rv == APR_SUCCESS)
rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool);
return rv;
@@ -419,7 +420,7 @@ APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_f
}
}
- if (parent_err != NULL && rv == APR_SUCCESS) {
+ if (parent_err != NULL && rv == APR_SUCCESS)
rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool);
return rv;
diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c
index b9a674b7f..8deb6de2f 100644
--- a/threadproc/unix/proc.c
+++ b/threadproc/unix/proc.c
@@ -396,7 +396,6 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
return errno;
}
else if (new->pid == 0) {
- int status;
/* child process */
/*
@@ -478,7 +477,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
}
/* Only try to switch if we are running as root */
if (attr->gid != -1 && !geteuid()) {
- if ((status = setgid(attr->gid))) {
+ if (setgid(attr->gid)) {
if (attr->errfn) {
attr->errfn(pool, errno, "setting of group failed");
}
@@ -487,7 +486,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
}
if (attr->uid != -1 && !geteuid()) {
- if ((status = setuid(attr->uid))) {
+ if (setuid(attr->uid)) {
if (attr->errfn) {
attr->errfn(pool, errno, "setting of user failed");
}
@@ -495,7 +494,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
}
}
- if ((status = limit_proc(attr)) != APR_SUCCESS) {
+ if (limit_proc(attr) != APR_SUCCESS) {
if (attr->errfn) {
attr->errfn(pool, errno, "setting of resource limits failed");
}
diff --git a/threadproc/unix/procsup.c b/threadproc/unix/procsup.c
index 376baf21f..94177f92a 100644
--- a/threadproc/unix/procsup.c
+++ b/threadproc/unix/procsup.c
@@ -18,8 +18,6 @@
APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize)
{
- int x;
-
if (chdir("/") == -1) {
return errno;
}
@@ -28,6 +26,8 @@ APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize)
/* Don't detach for MPE because child processes can't survive the death of
* the parent. */
if (daemonize) {
+ int x;
+
if ((x = fork()) > 0) {
exit(0);
}