Fixed some minor checkpatch warnings such as whitespace.
Coccinelle was used for this patch (NOTE: some of the changes were made by hand). The script is not complete (semantically) and might raise some checkpatch warnings in terms of indentation depending on existing code.
*** IFASSIGNMENT.COCCI START ***
/* Coccinelle script to handle assignments in if statements
 * For compound statements, can so far only handle statements with the
 * assignment on either extreme */
/* This rule is for simple cases
 * e.g. just an assignment in if, possibly with unary operator */
@simple@
expression E1, E2;
statement S1, S2;
@@
+ E1 = E2;
if (
- (E1 = E2)
+ E1
 )
S1 else S2
/* This rule is for compound statements where the assignment is on the right.*/
@right@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ } else S2
|
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1
+ }
/* or */
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ }
+ else S1
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1) S1
+ } else
S1
/* not equal */
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1 else S2
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1
/* equal */
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1 else S2
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1
/* greater than */
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1 else S2
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1
/* less than */
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1 else S2
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1
/* lesser than or equal to */
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1 else S2
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1
/* greater than or equal to */
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1 else S2
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1
)
/* This rule is for compound statements where the assignment is on the left.*/
@left@
expression E, E1, E2;
statement S1, S2;
@@
(
/* and */
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1 else S2
|
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1
|
/* or */
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1
|
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1 else S2
|
/* not equal */
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1
|
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1 else S2
|
/* equal */
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1
|
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1 else S2
|
/* greater */
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1
|
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1 else S2
|
/* less */
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1
|
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1 else S2
/* lesser than or equal to */
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1
|
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1 else S2
/* greater than or equal to */
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1
|
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1 else S2
)
*** IFASSIGNMENT.COCCI END ***
Signed-off-by: Chi Pham <fempsci@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 
        /* NB we can't trust socket ops to either consume our iovs
         * or leave them alone. */
-       if ((addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages)) != NULL) {
+       addr = ksocknal_lib_kiov_vmap(kiov, niov, scratchiov, pages);
+       if (addr != NULL) {
                nob = scratchiov[0].iov_len;
                msg.msg_iovlen = 1;
 
 
        LASSERT (tx_ack == NULL ||
                 tx_ack->tx_msg.ksm_type == KSOCK_MSG_NOOP);
 
-       if ((tx = conn->ksnc_tx_carrier) == NULL) {
+       tx = conn->ksnc_tx_carrier;
+       if (tx == NULL) {
                if (tx_ack != NULL) {
                        list_add_tail(&tx_ack->tx_list,
                                          &conn->ksnc_tx_queue);
        if (tx == NULL)
                return -ENOMEM;
 
-       if ((rc = ksocknal_launch_packet(peer->ksnp_ni, tx, peer->ksnp_id)) == 0)
+       rc = ksocknal_launch_packet(peer->ksnp_ni, tx, peer->ksnp_id);
+       if (rc == 0)
                return 0;
 
        ksocknal_free_tx(tx);
 
 void cfs_cap_raise(cfs_cap_t cap)
 {
        struct cred *cred;
-       if ((cred = prepare_creds())) {
+       cred = prepare_creds();
+       if (cred) {
                cap_raise(cred->cap_effective, cap);
                commit_creds(cred);
        }
 void cfs_cap_lower(cfs_cap_t cap)
 {
        struct cred *cred;
-       if ((cred = prepare_creds())) {
+       cred = prepare_creds();
+       if (cred) {
                cap_lower(cred->cap_effective, cap);
                commit_creds(cred);
        }
 
        CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data);
        if (strncmp(opt, data, strlen(opt)))
                return NULL;
-       if ((value = strchr(data, '=')) == NULL)
+       value = strchr(data, '=');
+       if (value == NULL)
                return NULL;
 
        value++;
 
 
        *lsmp = NULL;
        LASSERT(atomic_read(&lsm->lsm_refc) > 0);
-       if ((refc = atomic_dec_return(&lsm->lsm_refc)) == 0) {
+       refc = atomic_dec_return(&lsm->lsm_refc);
+       if (refc == 0) {
                LASSERT(lsm_op_find(lsm->lsm_magic) != NULL);
                lsm_op_find(lsm->lsm_magic)->lsm_free(lsm);
        }
 
        rc = llog_cat_process(NULL, llh, changelog_kkuc_cb, cs, 0, 0);
 
        /* Send EOF no matter what our result */
-       if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch),
-                                     cs->cs_flags))) {
+       kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch), cs->cs_flags);
+       if (kuch) {
                kuch->kuc_msgtype = CL_EOF;
                libcfs_kkuc_msg_put(cs->cs_fp, kuch);
        }
        if (rc)
                CERROR("ptlrpc_queue_wait failed, rc: %d\n", rc);
 
-       if (req->rq_repmsg &&
-           (oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL))) {
-               *oqctl = *oqc;
+       if (req->rq_repmsg) {
+               oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
+               if (oqc) {
+                       *oqctl = *oqc;
+               } else if (!rc) {
+                       CERROR ("Can't unpack obd_quotactl\n");
+                       rc = -EPROTO;
+               }
        } else if (!rc) {
-               CERROR ("Can't unpack obd_quotactl\n");
+               CERROR("Can't unpack obd_quotactl\n");
                rc = -EPROTO;
        }
        ptlrpc_req_finished(req);
 
        if (!buf)
                return 1;
 
-       if ((ptr = strstr(buf, key)) == NULL)
+       ptr = strstr(buf, key);
+       if (ptr == NULL)
                return 1;
 
        if (valp)
 
        if (rc)
                CERROR("ptlrpc_queue_wait failed, rc: %d\n", rc);
 
-       if (req->rq_repmsg &&
-           (oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL))) {
-               *oqctl = *oqc;
+       if (req->rq_repmsg) {
+               oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
+               if (oqc) {
+                       *oqctl = *oqc;
+               } else if (!rc) {
+                       CERROR("Can't unpack obd_quotactl\n");
+                       rc = -EPROTO;
+               }
        } else if (!rc) {
-               CERROR ("Can't unpack obd_quotactl\n");
+               CERROR("Can't unpack obd_quotactl\n");
                rc = -EPROTO;
        }
        ptlrpc_req_finished(req);
 
        sf = *(*buf)++;
        (*bufsize)--;
        if (sf & 0x80) {
-               if ((sf &= 0x7f) > ((*bufsize) - 1))
+               sf &= 0x7f;
+               if (((*bufsize) - 1) < sf)
                        return -1;
                if (sf > SIZEOF_INT)
                        return -1;
        rawobj_t toid;
        int ret = 0;
 
-       if ((toksize -= 1) < 0)
+       toksize -= 1;
+       if (0 > toksize)
                return (G_BAD_TOK_HEADER);
        if (*buf++ != 0x60)
                return (G_BAD_TOK_HEADER);
 
-       if ((seqsize = der_read_length(&buf, &toksize)) < 0)
+       seqsize = der_read_length(&buf, &toksize);
+       if (seqsize < 0)
                return(G_BAD_TOK_HEADER);
 
        if (seqsize != toksize)
                return (G_BAD_TOK_HEADER);
 
-       if ((toksize -= 1) < 0)
+       toksize -= 1;
+       if (0 > toksize)
                return (G_BAD_TOK_HEADER);
        if (*buf++ != 0x06)
                return (G_BAD_TOK_HEADER);
 
-       if ((toksize -= 1) < 0)
+       toksize -= 1;
+       if (0 > toksize)
                return (G_BAD_TOK_HEADER);
        toid.len = *buf++;
 
-       if ((toksize -= toid.len) < 0)
+       toksize -= toid.len;
+       if (0 > toksize)
                return (G_BAD_TOK_HEADER);
        toid.data = buf;
        buf += toid.len;
         * important to return G_BAD_TOK_HEADER if the token header is
         * in fact bad
         */
-       if ((toksize -= 2) < 0)
+       toksize -= 2;
+       if (0 > toksize)
                return (G_BAD_TOK_HEADER);
 
        if (ret)
        int ret = 0;
        int seqsize;
 
-       if ((len -= 1) < 0)
+       len -= 1;
+       if (0 > len)
                return (G_BAD_TOK_HEADER);
        if (*buf++ != 0x60)
                return (G_BAD_TOK_HEADER);
 
-       if ((seqsize = der_read_length(&buf, &len)) < 0)
+       seqsize = der_read_length(&buf, &len);
+       if (seqsize < 0)
                return (G_BAD_TOK_HEADER);
 
-       if ((len -= 1) < 0)
+       len -= 1;
+       if (0 > len)
                return (G_BAD_TOK_HEADER);
        if (*buf++ != 0x06)
                return (G_BAD_TOK_HEADER);
 
-       if ((len -= 1) < 0)
+       len -= 1;
+       if (0 > len)
                return (G_BAD_TOK_HEADER);
        mech->len = *buf++;
 
-       if ((len -= mech->len) < 0)
+       len -= mech->len;
+       if (0 > len)
                return (G_BAD_TOK_HEADER);
        OBD_ALLOC_LARGE(mech->data, mech->len);
        if (!mech->data)