aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lustre/obdclass/llog.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/lustre/lustre/obdclass/llog.c')
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index f956d7ed6785..992573eae1b1 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -76,8 +76,6 @@ static struct llog_handle *llog_alloc_handle(void)
*/
static void llog_free_handle(struct llog_handle *loghandle)
{
- LASSERT(loghandle != NULL);
-
/* failed llog_init_handle */
if (!loghandle->lgh_hdr)
goto out;
@@ -115,7 +113,7 @@ static int llog_read_header(const struct lu_env *env,
if (rc)
return rc;
- if (lop->lop_read_header == NULL)
+ if (!lop->lop_read_header)
return -EOPNOTSUPP;
rc = lop->lop_read_header(env, handle);
@@ -144,7 +142,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
struct llog_log_hdr *llh;
int rc;
- LASSERT(handle->lgh_hdr == NULL);
+ LASSERT(!handle->lgh_hdr);
llh = kzalloc(sizeof(*llh), GFP_NOFS);
if (!llh)
@@ -228,11 +226,11 @@ static int llog_process_thread(void *arg)
return 0;
}
- if (cd != NULL) {
+ if (cd) {
last_called_index = cd->lpcd_first_idx;
index = cd->lpcd_first_idx + 1;
}
- if (cd != NULL && cd->lpcd_last_idx)
+ if (cd && cd->lpcd_last_idx)
last_index = cd->lpcd_last_idx;
else
last_index = LLOG_BITMAP_BYTES * 8 - 1;
@@ -262,7 +260,8 @@ repeat:
/* NB: when rec->lrh_len is accessed it is already swabbed
* since it is used at the "end" of the loop and the rec
- * swabbing is done at the beginning of the loop. */
+ * swabbing is done at the beginning of the loop.
+ */
for (rec = (struct llog_rec_hdr *)buf;
(char *)rec < buf + LLOG_CHUNK_SIZE;
rec = (struct llog_rec_hdr *)((char *)rec + rec->lrh_len)) {
@@ -328,7 +327,7 @@ repeat:
}
out:
- if (cd != NULL)
+ if (cd)
cd->lpcd_last_idx = last_called_index;
kfree(buf);
@@ -366,27 +365,28 @@ int llog_process_or_fork(const struct lu_env *env,
int rc;
lpi = kzalloc(sizeof(*lpi), GFP_NOFS);
- if (!lpi) {
- CERROR("cannot alloc pointer\n");
+ if (!lpi)
return -ENOMEM;
- }
lpi->lpi_loghandle = loghandle;
lpi->lpi_cb = cb;
lpi->lpi_cbdata = data;
lpi->lpi_catdata = catdata;
if (fork) {
+ struct task_struct *task;
+
/* The new thread can't use parent env,
- * init the new one in llog_process_thread_daemonize. */
+ * init the new one in llog_process_thread_daemonize.
+ */
lpi->lpi_env = NULL;
init_completion(&lpi->lpi_completion);
- rc = PTR_ERR(kthread_run(llog_process_thread_daemonize, lpi,
- "llog_process_thread"));
- if (IS_ERR_VALUE(rc)) {
+ task = kthread_run(llog_process_thread_daemonize, lpi,
+ "llog_process_thread");
+ if (IS_ERR(task)) {
+ rc = PTR_ERR(task);
CERROR("%s: cannot start thread: rc = %d\n",
loghandle->lgh_ctxt->loc_obd->obd_name, rc);
- kfree(lpi);
- return rc;
+ goto out_lpi;
}
wait_for_completion(&lpi->lpi_completion);
} else {
@@ -394,6 +394,7 @@ int llog_process_or_fork(const struct lu_env *env,
llog_process_thread(lpi);
}
rc = lpi->lpi_rc;
+out_lpi:
kfree(lpi);
return rc;
}
@@ -416,13 +417,13 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt,
LASSERT(ctxt);
LASSERT(ctxt->loc_logops);
- if (ctxt->loc_logops->lop_open == NULL) {
+ if (!ctxt->loc_logops->lop_open) {
*lgh = NULL;
return -EOPNOTSUPP;
}
*lgh = llog_alloc_handle();
- if (*lgh == NULL)
+ if (!*lgh)
return -ENOMEM;
(*lgh)->lgh_ctxt = ctxt;
(*lgh)->lgh_logops = ctxt->loc_logops;
@@ -449,7 +450,7 @@ int llog_close(const struct lu_env *env, struct llog_handle *loghandle)
rc = llog_handle2ops(loghandle, &lop);
if (rc)
goto out;
- if (lop->lop_close == NULL) {
+ if (!lop->lop_close) {
rc = -EOPNOTSUPP;
goto out;
}