From 3c1f519956598b0106bd639f0ccae30ce745eb54 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Fri, 21 Feb 2014 20:01:28 +0400 Subject: [PATCH] LU-4629 osc: remove constant checks Comparison of unsigned value against 0 is always true or false Signed-off-by: Dmitry Eremin Change-Id: Ib03cd9e401d006cce5a8a2f49220458941d2ef19 Reviewed-on: http://review.whamcloud.com/9348 Tested-by: Jenkins Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/liblustre/rw.c | 17 ++++++++--------- lustre/osc/osc_cache.c | 12 ++++++------ lustre/utils/gss/svcgssd_proc.c | 25 ++++++++++++++++--------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index 54c6eaf..6c175b6 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -182,18 +182,17 @@ static int llu_file_rwx(struct inode *ino, struct ioctx *ioctx, int read) { - struct llu_io_session *session; - ssize_t cc; - int cmd = read ? OBD_BRW_READ : OBD_BRW_WRITE; - ENTRY; + struct llu_io_session *session; + ssize_t cc; + int cmd = read ? OBD_BRW_READ : OBD_BRW_WRITE; + ENTRY; - LASSERT(ioctx->ioctx_xtvlen >= 0); - LASSERT(ioctx->ioctx_iovlen >= 0); + LASSERT(ioctx->ioctx_iovlen > 0); - liblustre_wait_event(0); + liblustre_wait_event(0); - if (!ioctx->ioctx_xtvlen) - RETURN(0); + if (ioctx->ioctx_xtvlen == 0) + RETURN(0); /* XXX consider other types later */ if (S_ISDIR(llu_i2stat(ino)->st_mode)) diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 75f58fe..7c47536 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -1788,9 +1788,9 @@ static void osc_process_ar(struct osc_async_rc *ar, __u64 xid, * involved in the bulk transfer are no longer considered unstable. */ void osc_dec_unstable_pages(struct ptlrpc_request *req) { - struct ptlrpc_bulk_desc *desc = req->rq_bulk; - struct client_obd *cli = &req->rq_import->imp_obd->u.cli; - obd_count page_count = desc->bd_iov_count; + struct ptlrpc_bulk_desc *desc = req->rq_bulk; + struct client_obd *cli = &req->rq_import->imp_obd->u.cli; + int page_count = desc->bd_iov_count; int i; /* No unstable page tracking */ @@ -1817,9 +1817,9 @@ void osc_dec_unstable_pages(struct ptlrpc_request *req) /* "unstable" page accounting. See: osc_dec_unstable_pages. */ void osc_inc_unstable_pages(struct ptlrpc_request *req) { - struct ptlrpc_bulk_desc *desc = req->rq_bulk; - struct client_obd *cli = &req->rq_import->imp_obd->u.cli; - obd_count page_count = desc->bd_iov_count; + struct ptlrpc_bulk_desc *desc = req->rq_bulk; + struct client_obd *cli = &req->rq_import->imp_obd->u.cli; + int page_count = desc->bd_iov_count; int i; /* No unstable page tracking */ diff --git a/lustre/utils/gss/svcgssd_proc.c b/lustre/utils/gss/svcgssd_proc.c index 6a1fe4e..22f2f17 100644 --- a/lustre/utils/gss/svcgssd_proc.c +++ b/lustre/utils/gss/svcgssd_proc.c @@ -487,6 +487,7 @@ handle_nullreq(FILE *f) { gss_cred_id_t svc_cred; u_int32_t maj_stat = GSS_S_FAILURE, min_stat = 0; u_int32_t ignore_min_stat; + int get_len; struct svc_cred cred; static char *lbuf = NULL; static int lbuflen = 0; @@ -508,21 +509,27 @@ handle_nullreq(FILE *f) { printerr(2, "handling req: svc %u, nid %016llx, idx %llx\n", lustre_svc, nid, handle_seq); - in_handle.length = (size_t) qword_get(&cp, in_handle.value, - sizeof(in_handle_buf)); - printerr(3, "in_handle: \n"); - print_hexl(3, in_handle.value, in_handle.length); + get_len = qword_get(&cp, in_handle.value, sizeof(in_handle_buf)); + if (get_len < 0) { + printerr(0, "WARNING: handle_nullreq: " + "failed parsing request\n"); + goto out_err; + } + in_handle.length = (size_t)get_len; - in_tok.length = (size_t) qword_get(&cp, in_tok.value, - sizeof(in_tok_buf)); - printerr(3, "in_tok: \n"); - print_hexl(3, in_tok.value, in_tok.length); + printerr(3, "in_handle:\n"); + print_hexl(3, in_handle.value, in_handle.length); - if (in_tok.length < 0) { + get_len = qword_get(&cp, in_tok.value, sizeof(in_tok_buf)); + if (get_len < 0) { printerr(0, "WARNING: handle_nullreq: " "failed parsing request\n"); goto out_err; } + in_tok.length = (size_t)get_len; + + printerr(3, "in_tok:\n"); + print_hexl(3, in_tok.value, in_tok.length); if (in_handle.length != 0) { /* CONTINUE_INIT case */ if (in_handle.length != sizeof(ctx)) { -- 1.8.3.1