2015-06-20 19:17:42

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 0/5] drop trivially useless initialization

These patches remove initializations of variables that are immediately
reassigned.


2015-06-20 19:17:49

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 1/5] staging: lustre: libcfs: drop trivially useless initialization

Remove initialization of a variable that is immediately reassigned.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
;
x = e;
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/staging/lustre/lustre/libcfs/fail.c | 2 +-
drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
--- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(cfs_cpt_table_free);
int
cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
{
- int rc = 0;
+ int rc;

rc = snprintf(buf, len, "%d\t: %d\n", 0, 0);
len -= rc;
diff -u -p a/drivers/staging/lustre/lustre/libcfs/fail.c b/drivers/staging/lustre/lustre/libcfs/fail.c
--- a/drivers/staging/lustre/lustre/libcfs/fail.c
+++ b/drivers/staging/lustre/lustre/libcfs/fail.c
@@ -123,7 +123,7 @@ EXPORT_SYMBOL(__cfs_fail_check_set);

int __cfs_fail_timeout_set(__u32 id, __u32 value, int ms, int set)
{
- int ret = 0;
+ int ret;

ret = __cfs_fail_check_set(id, value, set);
if (ret) {

2015-06-20 19:18:29

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 2/5] staging: lustre: llite: drop trivially useless initialization

Remove initialization of a variable that is immediately reassigned.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
;
x = e;
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/staging/lustre/lustre/llite/file.c | 2 +-
drivers/staging/lustre/lustre/llite/xattr_cache.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c
--- a/drivers/staging/lustre/lustre/llite/xattr_cache.c
+++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c
@@ -357,7 +357,7 @@ static int ll_xattr_cache_refill(struct
struct ll_inode_info *lli = ll_i2info(inode);
struct mdt_body *body;
__u32 *xsizes;
- int rc = 0, i;
+ int rc, i;



diff -u -p a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -3005,7 +3005,7 @@ int ll_getattr(struct vfsmount *mnt, str
struct inode *inode = d_inode(de);
struct ll_sb_info *sbi = ll_i2sbi(inode);
struct ll_inode_info *lli = ll_i2info(inode);
- int res = 0;
+ int res;

res = ll_inode_revalidate(de, MDS_INODELOCK_UPDATE |
MDS_INODELOCK_LOOKUP);

2015-06-20 19:18:12

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 3/5] staging: lustre: lmv: drop trivially useless initialization

Remove initialization of a variable that is immediately reassigned.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
;
x = e;
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -1993,7 +1993,7 @@ static int lmv_setattr(struct obd_export
struct obd_device *obd = exp->exp_obd;
struct lmv_obd *lmv = &obd->u.lmv;
struct lmv_tgt_desc *tgt;
- int rc = 0;
+ int rc;

rc = lmv_check_connect(obd);
if (rc)

2015-06-20 19:18:06

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 4/5] staging: lustre: obdclass: llog: drop trivially useless initialization

Remove initialization of a variable that is immediately reassigned.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
;
x = e;
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/staging/lustre/lustre/obdclass/llog.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -907,7 +907,7 @@ int llog_is_empty(const struct lu_env *e
char *name)
{
struct llog_handle *llh;
- int rc = 0;
+ int rc;

rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
if (rc < 0) {

2015-06-20 19:17:59

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 5/5] staging: lustre: osc: drop trivially useless initialization

Remove initialization of a variable that is immediately reassigned.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
;
x = e;
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/staging/lustre/lustre/osc/osc_page.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -471,7 +471,7 @@ static int osc_page_flush(const struct l
struct cl_io *io)
{
struct osc_page *opg = cl2osc_page(slice);
- int rc = 0;
+ int rc;

rc = osc_flush_async_page(env, io, opg);
return rc;

2015-06-20 21:44:29

by Joachim Eastwood

[permalink] [raw]
Subject: Re: [PATCH 5/5] staging: lustre: osc: drop trivially useless initialization

On 20 June 2015 at 21:07, Julia Lawall <[email protected]> wrote:
> Remove initialization of a variable that is immediately reassigned.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> type T;
> identifier x;
> constant C;
> expression e;
> @@
>
> T x
> - = C
> ;
> x = e;
> // </smpl>
>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> drivers/staging/lustre/lustre/osc/osc_page.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff -u -p a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
> --- a/drivers/staging/lustre/lustre/osc/osc_page.c
> +++ b/drivers/staging/lustre/lustre/osc/osc_page.c
> @@ -471,7 +471,7 @@ static int osc_page_flush(const struct l
> struct cl_io *io)
> {
> struct osc_page *opg = cl2osc_page(slice);
> - int rc = 0;
> + int rc;
>
> rc = osc_flush_async_page(env, io, opg);
> return rc;
>

The whole rc variable is kinda useless.

Why not make it just:
return osc_flush_async_page(env, io, opg);

regards,
Joachim Eastwood

2015-06-21 00:49:46

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 5/5] staging: lustre: osc: drop trivially useless initialization

On Sat, 20 Jun 2015, Joachim Eastwood wrote:

> On 20 June 2015 at 21:07, Julia Lawall <[email protected]> wrote:
> > Remove initialization of a variable that is immediately reassigned.
> >
> > The semantic patch that makes this change is as follows:
> > (http://coccinelle.lip6.fr/)
> >
> > // <smpl>
> > @@
> > type T;
> > identifier x;
> > constant C;
> > expression e;
> > @@
> >
> > T x
> > - = C
> > ;
> > x = e;
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <[email protected]>
> >
> > ---
> > drivers/staging/lustre/lustre/osc/osc_page.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff -u -p a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
> > --- a/drivers/staging/lustre/lustre/osc/osc_page.c
> > +++ b/drivers/staging/lustre/lustre/osc/osc_page.c
> > @@ -471,7 +471,7 @@ static int osc_page_flush(const struct l
> > struct cl_io *io)
> > {
> > struct osc_page *opg = cl2osc_page(slice);
> > - int rc = 0;
> > + int rc;
> >
> > rc = osc_flush_async_page(env, io, opg);
> > return rc;
> >
>
> The whole rc variable is kinda useless.
>
> Why not make it just:
> return osc_flush_async_page(env, io, opg);

Sure. I'll fix that.

julia