Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1290616 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2015-12-13 14:50 +0100 |
| Last post | 2015-12-21 20:20 +0100 |
| Articles | 20 on this page of 39 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-13 14:50 +0100
[PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-13 15:00 +0100
Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-14 08:00 +0100
Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-14 10:10 +0100
Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-14 10:40 +0100
Re: staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-14 11:10 +0100
[PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-13 15:00 +0100
Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions Joe Perches <joe@perches.com> - 2015-12-15 15:30 +0100
Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-15 15:50 +0100
Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions Joe Perches <joe@perches.com> - 2015-12-15 16:10 +0100
Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-15 18:50 +0100
Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions Joe Perches <joe@perches.com> - 2015-12-15 19:20 +0100
Re: staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-15 19:30 +0100
Re: staging: lustre: Delete unnecessary goto statements in six functions Joe Perches <joe@perches.com> - 2015-12-15 19:40 +0100
Re: staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-15 20:00 +0100
Re: staging: lustre: Delete unnecessary goto statements in six functions Joe Perches <joe@perches.com> - 2015-12-15 20:00 +0100
Re: staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-15 19:10 +0100
Re: staging: lustre: Delete unnecessary goto statements in six functions Joe Perches <joe@perches.com> - 2015-12-15 19:30 +0100
[PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-13 15:00 +0100
[PATCH 6/7] staging: lustre: A few checks less in mgc_process_recover_log() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-13 15:00 +0100
[PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-13 15:00 +0100
Re: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-14 12:10 +0100
Re: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-14 13:10 +0100
Re: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-14 13:40 +0100
Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-14 13:50 +0100
Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-14 15:00 +0100
Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-14 18:50 +0100
Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-15 12:50 +0100
Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-15 16:10 +0100
[PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-13 15:00 +0100
[PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-13 15:10 +0100
[PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-21 20:10 +0100
[PATCH v2 1/4] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-21 20:10 +0100
[PATCH v2 4/4] staging: lustre: Fix a jump label position in osc_get_info() SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-21 20:20 +0100
[PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-21 20:20 +0100
Re: [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-12-22 00:50 +0100
Re: [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-22 08:20 +0100
Re: [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection Dan Carpenter <dan.carpenter@oracle.com> - 2015-12-22 09:10 +0100
[PATCH v2 2/4] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-21 20:20 +0100
Page 1 of 2 [1] 2 Next page →
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-13 14:50 +0100 |
| Subject | [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations |
| Message-ID | <qFfce-yf-5@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 13 Dec 2015 14:40:14 +0100 Several update suggestions were taken into account from static source code analysis. Markus Elfring (7): Delete unnecessary goto statements in six functions Rename a jump label for ptlrpc_req_finished() calls Rename a jump label for a kfree(key) call Delete an unnecessary variable initialisation in mgc_process_recover_log() Less checks in mgc_process_recover_log() after error detection A few checks less in mgc_process_recover_log() after error detection Rename a jump label for module_put() calls drivers/staging/lustre/lustre/llite/file.c | 26 ++--- drivers/staging/lustre/lustre/llite/lloop.c | 8 +- drivers/staging/lustre/lustre/llite/namei.c | 13 +-- drivers/staging/lustre/lustre/llite/xattr.c | 20 ++-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 124 ++++++++++----------- drivers/staging/lustre/lustre/mgc/mgc_request.c | 53 ++++----- drivers/staging/lustre/lustre/osc/osc_request.c | 52 ++++----- drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 22 ++-- 8 files changed, 152 insertions(+), 166 deletions(-) -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-13 15:00 +0100 |
| Subject | [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls |
| Message-ID | <qFflU-CN-1@gated-at.bofh.it> |
| In reply to | #1290616 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 10:33:38 +0100
This issue was detected by using the Coccinelle software.
Choose a jump label according to the current Linux coding style convention.
I suggest to improve this implementation detail by the reuse of a script
like the following for the semantic patch language.
@rename_jump_label exists@
identifier work;
type return_type;
@@
return_type work(...)
{
... when any
goto
-out
+finish_request
;
... when any
-out
+finish_request
:
ptlrpc_req_finished(...);
... when any
}
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/lustre/lustre/llite/file.c | 26 +++++------
drivers/staging/lustre/lustre/llite/namei.c | 12 ++---
drivers/staging/lustre/lustre/llite/xattr.c | 20 ++++----
drivers/staging/lustre/lustre/mdc/mdc_request.c | 54 +++++++++++-----------
drivers/staging/lustre/lustre/osc/osc_request.c | 28 +++++------
drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 22 ++++-----
6 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 31cd6b3..b94df54 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -427,27 +427,27 @@ static int ll_intent_file_open(struct dentry *dentry, void *lmm,
*/
if (!it_disposition(itp, DISP_OPEN_OPEN) ||
it_open_error(DISP_OPEN_OPEN, itp))
- goto out;
+ goto finish_request;
ll_release_openhandle(inode, itp);
- goto out;
+ goto finish_request;
}
if (it_disposition(itp, DISP_LOOKUP_NEG)) {
rc = -ENOENT;
- goto out;
+ goto finish_request;
}
if (rc != 0 || it_open_error(DISP_OPEN_OPEN, itp)) {
rc = rc ? rc : it_open_error(DISP_OPEN_OPEN, itp);
CDEBUG(D_VFSTRACE, "lock enqueue: err: %d\n", rc);
- goto out;
+ goto finish_request;
}
rc = ll_prep_inode(&inode, req, NULL, itp);
if (!rc && itp->d.lustre.it_lock_mode)
ll_set_lock_data(sbi->ll_md_exp, inode, itp, NULL);
-out:
+finish_request:
ptlrpc_req_finished(req);
ll_intent_drop_lock(itp);
@@ -2900,13 +2900,13 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
oit.it_create_mode &= ~M_CHECK_STALE;
if (rc < 0) {
rc = ll_inode_revalidate_fini(inode, rc);
- goto out;
+ goto finish_request;
}
rc = ll_revalidate_it_finish(req, &oit, inode);
if (rc != 0) {
ll_intent_release(&oit);
- goto out;
+ goto finish_request;
}
/* Unlinked? Unhash dentry, so it is not picked up later by
@@ -2946,7 +2946,7 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
rc = ll_prep_inode(&inode, req, NULL, NULL);
}
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -3315,25 +3315,25 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
if (body == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
lmmsize = body->eadatasize;
if (lmmsize == 0) /* empty layout */ {
rc = 0;
- goto out;
+ goto finish_request;
}
lmm = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA, lmmsize);
if (lmm == NULL) {
rc = -EFAULT;
- goto out;
+ goto finish_request;
}
lvbdata = libcfs_kvzalloc(lmmsize, GFP_NOFS);
if (lvbdata == NULL) {
rc = -ENOMEM;
- goto out;
+ goto finish_request;
}
memcpy(lvbdata, lmm, lmmsize);
@@ -3345,7 +3345,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
lock->l_lvb_len = lmmsize;
unlock_res_and_lock(lock);
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 2113dd4..7501f70 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -686,7 +686,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
rc = ll_prep_inode(&inode, request, dir->i_sb, it);
if (rc) {
inode = ERR_PTR(rc);
- goto out;
+ goto finish_request;
}
LASSERT(hlist_empty(&inode->i_dentry));
@@ -697,7 +697,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n",
inode, inode->i_ino, inode->i_generation);
ll_set_lock_data(sbi->ll_md_exp, inode, it, NULL);
- out:
+ finish_request:
ptlrpc_req_finished(request);
return inode;
}
@@ -960,13 +960,13 @@ static int ll_unlink(struct inode *dir, struct dentry *dentry)
rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request);
ll_finish_md_op_data(op_data);
if (rc)
- goto out;
+ goto finish_request;
ll_update_times(request, dir);
ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_UNLINK, 1);
rc = ll_objects_destroy(request, dir);
- out:
+ finish_request:
ptlrpc_req_finished(request);
return rc;
}
@@ -1059,11 +1059,11 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir,
err = md_link(sbi->ll_md_exp, op_data, &request);
ll_finish_md_op_data(op_data);
if (err)
- goto out;
+ goto finish_request;
ll_update_times(request, dir);
ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1);
-out:
+finish_request:
ptlrpc_req_finished(request);
return err;
}
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index 660b8ac..8d3287c 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -390,19 +390,19 @@ getxattr_nocache:
/* only detect the xattr size */
if (size == 0) {
rc = body->eadatasize;
- goto out;
+ goto finish_request;
}
if (size < body->eadatasize) {
CERROR("server bug: replied size %u > %u\n",
body->eadatasize, (int)size);
rc = -ERANGE;
- goto out;
+ goto finish_request;
}
if (body->eadatasize == 0) {
rc = -ENODATA;
- goto out;
+ goto finish_request;
}
/* do not need swab xattr data */
@@ -410,7 +410,7 @@ getxattr_nocache:
body->eadatasize);
if (!xdata) {
rc = -EFAULT;
- goto out;
+ goto finish_request;
}
memcpy(buffer, xdata, body->eadatasize);
@@ -425,14 +425,14 @@ getxattr_nocache:
(posix_acl_xattr_header *)buffer, rc);
if (IS_ERR(acl)) {
rc = PTR_ERR(acl);
- goto out;
+ goto finish_request;
}
rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode),
xattr_type, acl);
if (unlikely(rc < 0)) {
lustre_ext_acl_xattr_free(acl);
- goto out;
+ goto finish_request;
}
}
#endif
@@ -444,7 +444,7 @@ out_xattr:
ll_get_fsname(inode->i_sb, NULL, 0), rc);
sbi->ll_flags &= ~LL_SBI_USER_XATTR;
}
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -555,7 +555,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
rc = ll_getxattr_common(inode, NULL, buffer, size, OBD_MD_FLXATTRLS);
if (rc < 0)
- goto out;
+ goto finish_request;
if (buffer != NULL) {
struct ll_sb_info *sbi = ll_i2sbi(inode);
@@ -589,7 +589,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
if (rc2 < 0) {
rc2 = 0;
- goto out;
+ goto finish_request;
} else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) {
const int prefix_len = sizeof(XATTR_LUSTRE_PREFIX) - 1;
const size_t name_len = sizeof("lov") - 1;
@@ -608,7 +608,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
}
rc2 = total_len;
}
-out:
+finish_request:
ptlrpc_req_finished(request);
rc = rc + rc2;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 920b1e9..2a76685 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -92,12 +92,12 @@ static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid)
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
if (body == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*rootfid = body->fid1;
@@ -105,7 +105,7 @@ static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid)
"root fid="DFID", last_committed=%llu\n",
PFID(rootfid),
lustre_msg_get_last_committed(req->rq_repmsg));
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -1084,17 +1084,17 @@ static int mdc_statfs(const struct lu_env *env,
/* check connection error first */
if (imp->imp_connect_error)
rc = imp->imp_connect_error;
- goto out;
+ goto finish_request;
}
msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
if (msfs == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*osfs = *msfs;
-out:
+finish_request:
ptlrpc_req_finished(req);
output:
class_import_put(imp);
@@ -1163,7 +1163,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
LUSTRE_MDS_VERSION, MDS_HSM_PROGRESS);
if (req == NULL) {
rc = -ENOMEM;
- goto out;
+ goto finish_request;
}
mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
@@ -1172,7 +1172,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS);
if (req_hpk == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*req_hpk = *hpk;
@@ -1181,7 +1181,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
ptlrpc_request_set_replen(req);
rc = mdc_queue_wait(req);
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -1197,7 +1197,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
MDS_HSM_CT_REGISTER);
if (req == NULL) {
rc = -ENOMEM;
- goto out;
+ goto finish_request;
}
mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
@@ -1207,7 +1207,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
&RMF_MDS_HSM_ARCHIVE);
if (archive_mask == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*archive_mask = archives;
@@ -1215,7 +1215,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
ptlrpc_request_set_replen(req);
rc = mdc_queue_wait(req);
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -1246,18 +1246,18 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp,
rc = mdc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
req_hca = req_capsule_server_get(&req->rq_pill,
&RMF_MDS_HSM_CURRENT_ACTION);
if (req_hca == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*hca = *req_hca;
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -1272,7 +1272,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
MDS_HSM_CT_UNREGISTER);
if (req == NULL) {
rc = -ENOMEM;
- goto out;
+ goto finish_request;
}
mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
@@ -1280,7 +1280,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
ptlrpc_request_set_replen(req);
rc = mdc_queue_wait(req);
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -1311,17 +1311,17 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp,
rc = mdc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
req_hus = req_capsule_server_get(&req->rq_pill, &RMF_HSM_USER_STATE);
if (req_hus == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*hus = *req_hus;
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -1352,14 +1352,14 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
req_hss = req_capsule_client_get(&req->rq_pill, &RMF_HSM_STATE_SET);
if (req_hss == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*req_hss = *hss;
ptlrpc_request_set_replen(req);
rc = mdc_queue_wait(req);
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -1377,7 +1377,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST);
if (req == NULL) {
rc = -ENOMEM;
- goto out;
+ goto finish_request;
}
req_capsule_set_size(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM, RCL_CLIENT,
@@ -1398,7 +1398,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
req_hr = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_REQUEST);
if (req_hr == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*req_hr = hur->hur_request;
@@ -1406,7 +1406,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
req_hui = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM);
if (req_hui == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
memcpy(req_hui, hur->hur_user_item,
hur->hur_request.hr_itemcount * sizeof(struct hsm_user_item));
@@ -1415,14 +1415,14 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
req_opaque = req_capsule_client_get(&req->rq_pill, &RMF_GENERIC_DATA);
if (req_opaque == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
memcpy(req_opaque, hur_data(hur), hur->hur_request.hr_data_len);
ptlrpc_request_set_replen(req);
rc = mdc_queue_wait(req);
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index d6c1447..3a56fb7 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -291,12 +291,12 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
if (body == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode);
@@ -306,7 +306,7 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
oinfo->oi_oa->o_blksize = cli_brw_size(exp->exp_obd);
oinfo->oi_oa->o_valid |= OBD_MD_FLBLKSZ;
- out:
+ finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -336,18 +336,18 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp,
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
if (body == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oinfo->oi_oa,
&body->oa);
-out:
+finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -1276,7 +1276,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
if (desc == NULL) {
rc = -ENOMEM;
- goto out;
+ goto finish_request;
}
/* NB request now owns desc and will free it when it gets freed */
@@ -1407,7 +1407,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
*reqp = req;
return 0;
- out:
+ finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -2513,17 +2513,17 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp,
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
if (msfs == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*osfs = *msfs;
- out:
+ finish_request:
ptlrpc_req_finished(req);
return rc;
}
@@ -2718,16 +2718,16 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp,
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
reply = req_capsule_server_get(&req->rq_pill, &RMF_OBD_ID);
if (reply == NULL) {
rc = -EPROTO;
- goto out;
+ goto finish_request;
}
*((u64 *)val) = *reply;
- out:
+ finish_request:
ptlrpc_req_finished(req);
return rc;
} else if (KEY_IS(KEY_FIEMAP)) {
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
index 5122205..150d2ec 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
@@ -176,26 +176,26 @@ static int llog_client_next_block(const struct lu_env *env,
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
if (body == NULL) {
rc = -EFAULT;
- goto out;
+ goto finish_request;
}
/* The log records are swabbed as they are processed */
ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
if (ptr == NULL) {
rc = -EFAULT;
- goto out;
+ goto finish_request;
}
*cur_idx = body->lgd_saved_index;
*cur_offset = body->lgd_cur_offset;
memcpy(buf, ptr, len);
-out:
+finish_request:
ptlrpc_req_finished(req);
err_exit:
LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp);
@@ -233,22 +233,22 @@ static int llog_client_prev_block(const struct lu_env *env,
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
if (body == NULL) {
rc = -EFAULT;
- goto out;
+ goto finish_request;
}
ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
if (ptr == NULL) {
rc = -EFAULT;
- goto out;
+ goto finish_request;
}
memcpy(buf, ptr, len);
-out:
+finish_request:
ptlrpc_req_finished(req);
err_exit:
LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp);
@@ -282,12 +282,12 @@ static int llog_client_read_header(const struct lu_env *env,
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR);
if (hdr == NULL) {
rc = -EFAULT;
- goto out;
+ goto finish_request;
}
memcpy(handle->lgh_hdr, hdr, sizeof(*hdr));
@@ -305,7 +305,7 @@ static int llog_client_read_header(const struct lu_env *env,
CERROR("you may need to re-run lconf --write_conf.\n");
rc = -EIO;
}
-out:
+finish_request:
ptlrpc_req_finished(req);
err_exit:
LLOG_CLIENT_EXIT(handle->lgh_ctxt, imp);
--
2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2015-12-14 08:00 +0100 |
| Subject | Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls |
| Message-ID | <qFvh0-2xT-11@gated-at.bofh.it> |
| In reply to | #1290617 |
Markus, please stop sending these things to rename out labels unless there is a bug. CodingStyle allows out labels. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-14 10:10 +0100 |
| Subject | Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls |
| Message-ID | <qFxiN-43P-7@gated-at.bofh.it> |
| In reply to | #1290890 |
> Markus, please stop sending these things to rename out labels unless > there is a bug. CodingStyle allows out labels. How does this feedback fit to information like the following? "… Chapter 7: … … Choose label names which say what the goto does or why the goto exists. … Avoid using GW-BASIC names … …" Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2015-12-14 10:40 +0100 |
| Subject | Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls |
| Message-ID | <qFxLQ-4dP-23@gated-at.bofh.it> |
| In reply to | #1290989 |
On Mon, Dec 14, 2015 at 10:08:03AM +0100, SF Markus Elfring wrote: > > Markus, please stop sending these things to rename out labels unless > > there is a bug. CodingStyle allows out labels. > > How does this feedback fit to information like the following? > > "… > Chapter 7: … > … > Choose label names which say what the goto does or why the goto exists. A lot of people think "out" says what the goto does and why it exists. I personally don't agree with them but if you look at when I complain about it, it's almost always when it causes a bug. > … Avoid using GW-BASIC names … Those when people just use numbers for their label names instead of words like out1, out2, out4, out5. It's a different thing. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-14 11:10 +0100 |
| Subject | Re: staging: lustre: Rename a jump label for ptlrpc_req_finished() calls |
| Message-ID | <qFyeU-4Fp-29@gated-at.bofh.it> |
| In reply to | #1291008 |
>>> Markus, please stop sending these things to rename out labels unless >>> there is a bug. CodingStyle allows out labels. >> >> How does this feedback fit to information like the following? >> >> "… >> Chapter 7: … >> … >> Choose label names which say what the goto does or why the goto exists. > > A lot of people think "out" says what the goto does and why it exists. I have got the impression that this short identifier is only partly appropriate. > I personally don't agree with them I guess that my opinion goes into a similar direction here. > but if you look at when I complain about it, it's almost always > when it causes a bug. I agree that the combination with bug fixing is more appealing than an attempt to improve coding style applications. >> … Avoid using GW-BASIC names … > > Those when people just use numbers for their label names instead of > words like out1, out2, out4, out5. It's a different thing. The difference is not so clear for me as it appears to you. How many software developers can still remember habits around the selection of such identifiers from GW-BASIC times? Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-13 15:00 +0100 |
| Subject | [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qFflU-CN-5@gated-at.bofh.it> |
| In reply to | #1290616 |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Sun, 13 Dec 2015 09:30:47 +0100 Six goto statements referred to a source code position directly behind them. Thus omit such unnecessary jumps. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> --- drivers/staging/lustre/lustre/llite/namei.c | 1 - drivers/staging/lustre/lustre/mdc/mdc_request.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 64db5e8..2113dd4 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -554,7 +554,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, retval = NULL; else retval = dentry; - goto out; out: if (req) ptlrpc_req_finished(req); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 294c050..920b1e9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1181,7 +1181,6 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; out: ptlrpc_req_finished(req); return rc; @@ -1216,7 +1215,6 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; out: ptlrpc_req_finished(req); return rc; @@ -1282,7 +1280,6 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp) ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; out: ptlrpc_req_finished(req); return rc; @@ -1362,8 +1359,6 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; - out: ptlrpc_req_finished(req); return rc; @@ -1427,8 +1422,6 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; - out: ptlrpc_req_finished(req); return rc; -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2015-12-15 15:30 +0100 |
| Subject | Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qFYM2-5hd-23@gated-at.bofh.it> |
| In reply to | #1290618 |
On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Sun, 13 Dec 2015 09:30:47 +0100 > > Six goto statements referred to a source code position directly behind them. > Thus omit such unnecessary jumps. I suggest you leave a blank line instead of deleting the goto. > diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c [] > @@ -554,7 +554,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, > retval = NULL; > else > retval = dentry; > - goto out; > out: > if (req) > ptlrpc_req_finished(req); etc.,, -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2015-12-15 15:50 +0100 |
| Subject | Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qFZ5o-5o7-13@gated-at.bofh.it> |
| In reply to | #1292219 |
On Tue, Dec 15, 2015 at 06:27:56AM -0800, Joe Perches wrote: > On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote: > > From: Markus Elfring <elfring@users.sourceforge.net> > > Date: Sun, 13 Dec 2015 09:30:47 +0100 > > > > Six goto statements referred to a source code position directly behind them. > > Thus omit such unnecessary jumps. > > I suggest you leave a blank line instead > of deleting the goto. > What is the point of the little bunny hop? regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2015-12-15 16:10 +0100 |
| Subject | Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qFZoJ-5LF-13@gated-at.bofh.it> |
| In reply to | #1292230 |
On Tue, 2015-12-15 at 17:41 +0300, Dan Carpenter wrote: > On Tue, Dec 15, 2015 at 06:27:56AM -0800, Joe Perches wrote: > > On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote: > > > From: Markus Elfring <elfring@users.sourceforge.net> > > > Date: Sun, 13 Dec 2015 09:30:47 +0100 > > > > > > Six goto statements referred to a source code position directly behind them. > > > Thus omit such unnecessary jumps. > > > > I suggest you leave a blank line instead > > of deleting the goto. > > > > What is the point of the little bunny hop? > > regards, > dan carpenter > -ENOPARSE little bunny hop (though I could have said "just leave a blank line) I think that code blocks are more obvious to read. This is the original code: result = foo(); if (result) goto label; result = bar(); if (result) goto label; result = baz(); if (result) goto label; label: go on... He proposes: result = foo(); if (result) goto label; result = bar(); if (result) goto label; result = baz(); label: go on... I don't find the test->goto label; label: use offensive, but if he does, I think keeping a blank line in place of the test->goto might be better. result = foo(); if (result) goto label; result = bar(); if (result) goto label; result = baz(); label: go on... -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2015-12-15 18:50 +0100 |
| Subject | Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qG1Tz-7mv-9@gated-at.bofh.it> |
| In reply to | #1292246 |
On Tue, Dec 15, 2015 at 07:02:31AM -0800, Joe Perches wrote: > This is the original code: > > result = foo(); > if (result) > goto label; > > result = bar(); > if (result) > goto label; > > result = baz(); > if (result) > goto label; > > label: > go on... > No. There is no test. The original code looks like: result = foo(); if (result) goto out; result = baz(); goto out; out: go on.. regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2015-12-15 19:20 +0100 |
| Subject | Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qG2mB-7LE-11@gated-at.bofh.it> |
| In reply to | #1292408 |
On Tue, 2015-12-15 at 20:48 +0300, Dan Carpenter wrote:
> On Tue, Dec 15, 2015 at 07:02:31AM -0800, Joe Perches wrote:
> > This is the original code:
> >
> > result = foo();
> > if (result)
> > goto label;
> >
> > result = bar();
> > if (result)
> > goto label;
> >
> > result = baz();
> > if (result)
> > goto label;
> >
> > label:
> > go on...
> >
>
> No. There is no test. The original code looks like:
>
> result = foo();
> if (result)
> goto out;
> result = baz();
> goto out;
> out:
> go on..
>
> regards,
> dan carpenter
Here is the original code:
---------------------
/* Copy hsm_progress struct */
req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS);
if (req_hpk == NULL) {
rc = -EPROTO;
goto out;
}
*req_hpk = *hpk;
req_hpk->hpk_errval = lustre_errno_hton(hpk->hpk_errval);
ptlrpc_request_set_replen(req);
rc = mdc_queue_wait(req);
goto out;
out:
ptlrpc_req_finished(req);
return rc;
}
---------------------
I think if the last goto out; is to be removed,
then it should be replaced by a blank line.
It separates the last operation block from the return.
cheers, Joe
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-15 19:30 +0100 |
| Subject | Re: staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qG2wi-7PJ-7@gated-at.bofh.it> |
| In reply to | #1292431 |
> rc = mdc_queue_wait(req); > goto out; > out: > ptlrpc_req_finished(req); > return rc; > } > --------------------- > > I think if the last goto out; is to be removed, > then it should be replaced by a blank line. > > It separates the last operation block from the return. Would you like to point a very specific coding style issue out? How often should jump labels preceded with blank lines? Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2015-12-15 19:40 +0100 |
| Subject | Re: staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qG2FY-7U3-13@gated-at.bofh.it> |
| In reply to | #1292436 |
On Tue, 2015-12-15 at 19:26 +0100, SF Markus Elfring wrote: > > rc = mdc_queue_wait(req); > > goto out; > > out: > > ptlrpc_req_finished(req); > > return rc; > > } > > --------------------- > > > > I think if the last goto out; is to be removed, > > then it should be replaced by a blank line. > > > > It separates the last operation block from the return. > > Would you like to point a very specific coding style issue out? Other than using vertical separation can help readability? I think there should _not_ be a hardened rule. Style is just a guide. Do what you think appropriate. > How often should jump labels preceded with blank lines? When other nearby blocks are also separated by blank lines. Localized consistency can be useful. Inconsistency can make code harder to follow/predict. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-15 20:00 +0100 |
| Subject | Re: staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qG2Zk-80R-3@gated-at.bofh.it> |
| In reply to | #1292452 |
> I think there should _not_ be a hardened rule. I guess that it can become hard to achieve consensus on a precise rule. > Style is just a guide. Generally nice … > Do what you think appropriate. I'm sorry for my evolving understanding. - But I imagine that your feedback can cause further software development troubles if the acceptance for this update suggestion will really depend on the number of blank lines before a jump label. Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2015-12-15 20:00 +0100 |
| Subject | Re: staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qG2Zk-80R-7@gated-at.bofh.it> |
| In reply to | #1292470 |
On Tue, 2015-12-15 at 19:49 +0100, SF Markus Elfring wrote: > > I think there should _not_ be a hardened rule. > I guess that it can become hard to achieve consensus on a precise rule. Consensus isn't unanimity. > I imagine that your feedback > can cause further software development troubles if the acceptance for > this update suggestion will really depend on the number of blank lines > before a jump label. <shrug> The author of any particular bit of code can do whatever they want. Localized consistency is probably more valuable than global consistency. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-15 19:10 +0100 |
| Subject | Re: staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qG2cW-7Iu-15@gated-at.bofh.it> |
| In reply to | #1292246 |
> This is the original code: Really …? > result = baz(); > if (result) > goto label; > > label: > go on... I do not see such a source code structure at the six places I propose to clean-up. > I don't find the test->goto label; label: use offensive, > but if he does, I think keeping a blank line in place of > the test->goto might be better. I find this an interesting view on source code layout. Are there any more opinions around such implementation details? Regards, Markus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2015-12-15 19:30 +0100 |
| Subject | Re: staging: lustre: Delete unnecessary goto statements in six functions |
| Message-ID | <qG2wi-7PJ-23@gated-at.bofh.it> |
| In reply to | #1292426 |
On Tue, 2015-12-15 at 19:02 +0100, SF Markus Elfring wrote:
> > This is the original code:
> Really …?
> > result = baz();
> > if (result)
> > goto label;
> >
> > label:
> > go on...
>
> I do not see such a source code structure
> at the six places I propose to clean-up.
>
>
> > I don't find the test->goto label; label: use offensive,
> > but if he does, I think keeping a blank line in place of
> > the test->goto might be better.
>
> I find this an interesting view on source code layout.
> Are there any more opinions around such implementation details?
Or to put it another way, use a blank line before the
first or only label in an error/out block.
I don't find it different then commonly written blocks like:
void foo(void)
{
...;
wind1();
val = func1(...);
if (val) {
printk(...);
goto err_type;
}
wind2();
val = func2(...);
if (val) {
printk(...);
goto err_type2;
}
...
return 0;
err_type2:
unwind2();
err_type:
unwind1();
return -ERR;
}
Yes, you can elide all the blank lines, but using them can
help readability.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-13 15:00 +0100 |
| Subject | [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call |
| Message-ID | <qFflU-CN-3@gated-at.bofh.it> |
| In reply to | #1290616 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 10:56:35 +0100
This issue was detected by using the Coccinelle software.
Choose a jump label according to the current Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/lustre/lustre/mdc/mdc_request.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 2a76685..2085ba6 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1125,7 +1125,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
if (!fid_is_sane(&gf->gf_fid)) {
rc = -EINVAL;
- goto out;
+ goto free_key;
}
/* Val is struct getinfo_fid2path result plus path */
@@ -1133,20 +1133,19 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
rc = obd_get_info(NULL, exp, keylen, key, &vallen, gf, NULL);
if (rc != 0 && rc != -EREMOTE)
- goto out;
+ goto free_key;
if (vallen <= sizeof(*gf)) {
rc = -EPROTO;
- goto out;
+ goto free_key;
} else if (vallen > sizeof(*gf) + gf->gf_pathlen) {
rc = -EOVERFLOW;
- goto out;
+ goto free_key;
}
CDEBUG(D_IOCTL, "path get "DFID" from %llu #%d\n%s\n",
PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
-
-out:
+free_key:
kfree(key);
return rc;
}
--
2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2015-12-13 15:00 +0100 |
| Subject | [PATCH 6/7] staging: lustre: A few checks less in mgc_process_recover_log() after error detection |
| Message-ID | <qFflU-CN-9@gated-at.bofh.it> |
| In reply to | #1290616 |
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 13:03:58 +0100
A few checks would be performed by the mgc_process_recover_log() function
even if it was determined that a call of the alloc_page() function failed.
* This implementation detail could be improved by adjustments
for jump targets according to the Linux coding style convention.
* Move the assignment for the variable "eof" behind the memory allocation.
* Delete another sanity check then.
* The variable "req" will eventually be set to an appropriate pointer
from a call of the ptlrpc_request_alloc() function.
Thus let us omit the explicit initialisation before.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/lustre/lustre/mgc/mgc_request.c | 32 +++++++++++--------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index f3b4c30..7048722 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1312,17 +1312,15 @@ static int mgc_process_recover_log(struct obd_device *obd,
if (!pages)
return -ENOMEM;
- req = NULL;
- eof = true;
-
for (i = 0; i < nrpages; i++) {
pages[i] = alloc_page(GFP_KERNEL);
if (pages[i] == NULL) {
rc = -ENOMEM;
- goto out;
+ goto free_pages;
}
}
+ eof = true;
again:
LASSERT(cld_is_recover(cld));
LASSERT(mutex_is_locked(&cld->cld_lock));
@@ -1330,12 +1328,12 @@ again:
&RQF_MGS_CONFIG_READ);
if (req == NULL) {
rc = -ENOMEM;
- goto out;
+ goto free_pages;
}
rc = ptlrpc_request_pack(req, LUSTRE_MGS_VERSION, MGS_CONFIG_READ);
if (rc)
- goto out;
+ goto finish_request;
/* pack request */
body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY);
@@ -1344,7 +1342,7 @@ again:
if (strlcpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name))
>= sizeof(body->mcb_name)) {
rc = -E2BIG;
- goto out;
+ goto finish_request;
}
body->mcb_offset = cfg->cfg_last_idx + 1;
body->mcb_type = cld->cld_type;
@@ -1356,7 +1354,7 @@ again:
MGS_BULK_PORTAL);
if (desc == NULL) {
rc = -ENOMEM;
- goto out;
+ goto finish_request;
}
for (i = 0; i < nrpages; i++)
@@ -1365,12 +1363,12 @@ again:
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
if (rc)
- goto out;
+ goto finish_request;
res = req_capsule_server_get(&req->rq_pill, &RMF_MGS_CONFIG_RES);
if (res->mcr_size < res->mcr_offset) {
rc = -EINVAL;
- goto out;
+ goto finish_request;
}
/* always update the index even though it might have errors with
@@ -1384,18 +1382,18 @@ again:
ealen = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk, 0);
if (ealen < 0) {
rc = ealen;
- goto out;
+ goto finish_request;
}
if (ealen > nrpages << PAGE_CACHE_SHIFT) {
rc = -EINVAL;
- goto out;
+ goto finish_request;
}
if (ealen == 0) { /* no logs transferred */
if (!eof)
rc = -EINVAL;
- goto out;
+ goto finish_request;
}
mne_swab = !!ptlrpc_rep_need_swab(req);
@@ -1425,14 +1423,12 @@ again:
ealen -= PAGE_CACHE_SIZE;
}
-
-out:
- if (req)
- ptlrpc_req_finished(req);
+finish_request:
+ ptlrpc_req_finished(req);
if (rc == 0 && !eof)
goto again;
-
+free_pages:
for (i = 0; i < nrpages; i++) {
if (pages[i] == NULL)
break;
--
2.6.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web