Skip to content

Commit cf7c33d

Browse files
martinetdericvh
authored andcommitted
9p: remove dead stores (variable set again without being read)
The 9p code for some reason used to initialize variables outside of the declaration, e.g. instead of just initializing the variable like this: int retval = 0 We would be doing this: int retval; retval = 0; This is perfectly fine and the compiler will just optimize dead stores anyway, but scan-build seems to think this is a problem and there are many of these warnings making the output of scan-build full of such warnings: fs/9p/vfs_inode.c:916:2: warning: Value stored to 'retval' is never read [deadcode.DeadStores] retval = 0; ^ ~ I have no strong opinion here, but if we want to regularly run scan-build we should fix these just to silence the messages. I've confirmed these all are indeed ok to remove. Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org> Signed-off-by: Eric Van Hensbergen <ericvh@kernel.org>
1 parent f41b402 commit cf7c33d

File tree

3 files changed

+12
-41
lines changed

3 files changed

+12
-41
lines changed

fs/9p/vfs_inode.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ int v9fs_uflags2omode(int uflags, int extended)
163163
{
164164
int ret;
165165

166-
ret = 0;
167166
switch (uflags&3) {
168167
default:
169168
case O_RDONLY:
@@ -603,7 +602,6 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
603602

604603
p9_debug(P9_DEBUG_VFS, "name %pd\n", dentry);
605604

606-
err = 0;
607605
name = dentry->d_name.name;
608606
dfid = v9fs_parent_fid(dentry);
609607
if (IS_ERR(dfid)) {
@@ -815,8 +813,6 @@ v9fs_vfs_atomic_open(struct inode *dir, struct dentry *dentry,
815813
if (!(flags & O_CREAT) || d_really_is_positive(dentry))
816814
return finish_no_open(file, res);
817815

818-
err = 0;
819-
820816
v9ses = v9fs_inode2v9ses(dir);
821817
perm = unixmode2p9mode(v9ses, mode);
822818
p9_omode = v9fs_uflags2omode(flags, v9fs_proto_dotu(v9ses));
@@ -912,7 +908,6 @@ v9fs_vfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
912908
return -EINVAL;
913909

914910
p9_debug(P9_DEBUG_VFS, "\n");
915-
retval = 0;
916911
old_inode = d_inode(old_dentry);
917912
new_inode = d_inode(new_dentry);
918913
v9ses = v9fs_inode2v9ses(old_inode);
@@ -1066,7 +1061,6 @@ static int v9fs_vfs_setattr(struct mnt_idmap *idmap,
10661061
if (retval)
10671062
return retval;
10681063

1069-
retval = -EPERM;
10701064
v9ses = v9fs_dentry2v9ses(dentry);
10711065
if (iattr->ia_valid & ATTR_FILE) {
10721066
fid = iattr->ia_file->private_data;

fs/9p/vfs_inode_dotl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ static int v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap,
366366
struct posix_acl *dacl = NULL, *pacl = NULL;
367367

368368
p9_debug(P9_DEBUG_VFS, "name %pd\n", dentry);
369-
err = 0;
370369
v9ses = v9fs_inode2v9ses(dir);
371370

372371
omode |= S_IFDIR;

net/9p/client.c

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ EXPORT_SYMBOL(do_trace_9p_fid_put);
904904

905905
static int p9_client_version(struct p9_client *c)
906906
{
907-
int err = 0;
907+
int err;
908908
struct p9_req_t *req;
909909
char *version = NULL;
910910
int msize;
@@ -975,7 +975,6 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
975975
struct p9_client *clnt;
976976
char *client_id;
977977

978-
err = 0;
979978
clnt = kmalloc(sizeof(*clnt), GFP_KERNEL);
980979
if (!clnt)
981980
return ERR_PTR(-ENOMEM);
@@ -1094,7 +1093,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
10941093
const char *uname, kuid_t n_uname,
10951094
const char *aname)
10961095
{
1097-
int err = 0;
1096+
int err;
10981097
struct p9_req_t *req;
10991098
struct p9_fid *fid;
11001099
struct p9_qid qid;
@@ -1147,7 +1146,6 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
11471146
struct p9_req_t *req;
11481147
u16 nwqids, count;
11491148

1150-
err = 0;
11511149
wqids = NULL;
11521150
clnt = oldfid->clnt;
11531151
if (clone) {
@@ -1224,7 +1222,6 @@ int p9_client_open(struct p9_fid *fid, int mode)
12241222
clnt = fid->clnt;
12251223
p9_debug(P9_DEBUG_9P, ">>> %s fid %d mode %d\n",
12261224
p9_is_proto_dotl(clnt) ? "TLOPEN" : "TOPEN", fid->fid, mode);
1227-
err = 0;
12281225

12291226
if (fid->mode != -1)
12301227
return -EINVAL;
@@ -1262,7 +1259,7 @@ EXPORT_SYMBOL(p9_client_open);
12621259
int p9_client_create_dotl(struct p9_fid *ofid, const char *name, u32 flags,
12631260
u32 mode, kgid_t gid, struct p9_qid *qid)
12641261
{
1265-
int err = 0;
1262+
int err;
12661263
struct p9_client *clnt;
12671264
struct p9_req_t *req;
12681265
int iounit;
@@ -1314,7 +1311,6 @@ int p9_client_fcreate(struct p9_fid *fid, const char *name, u32 perm, int mode,
13141311

13151312
p9_debug(P9_DEBUG_9P, ">>> TCREATE fid %d name %s perm %d mode %d\n",
13161313
fid->fid, name, perm, mode);
1317-
err = 0;
13181314
clnt = fid->clnt;
13191315

13201316
if (fid->mode != -1)
@@ -1350,7 +1346,7 @@ EXPORT_SYMBOL(p9_client_fcreate);
13501346
int p9_client_symlink(struct p9_fid *dfid, const char *name,
13511347
const char *symtgt, kgid_t gid, struct p9_qid *qid)
13521348
{
1353-
int err = 0;
1349+
int err;
13541350
struct p9_client *clnt;
13551351
struct p9_req_t *req;
13561352

@@ -1402,13 +1398,12 @@ EXPORT_SYMBOL(p9_client_link);
14021398

14031399
int p9_client_fsync(struct p9_fid *fid, int datasync)
14041400
{
1405-
int err;
1401+
int err = 0;
14061402
struct p9_client *clnt;
14071403
struct p9_req_t *req;
14081404

14091405
p9_debug(P9_DEBUG_9P, ">>> TFSYNC fid %d datasync:%d\n",
14101406
fid->fid, datasync);
1411-
err = 0;
14121407
clnt = fid->clnt;
14131408

14141409
req = p9_client_rpc(clnt, P9_TFSYNC, "dd", fid->fid, datasync);
@@ -1428,15 +1423,14 @@ EXPORT_SYMBOL(p9_client_fsync);
14281423

14291424
int p9_client_clunk(struct p9_fid *fid)
14301425
{
1431-
int err;
1426+
int err = 0;
14321427
struct p9_client *clnt;
14331428
struct p9_req_t *req;
14341429
int retries = 0;
14351430

14361431
again:
14371432
p9_debug(P9_DEBUG_9P, ">>> TCLUNK fid %d (try %d)\n",
14381433
fid->fid, retries);
1439-
err = 0;
14401434
clnt = fid->clnt;
14411435

14421436
req = p9_client_rpc(clnt, P9_TCLUNK, "d", fid->fid);
@@ -1465,12 +1459,11 @@ EXPORT_SYMBOL(p9_client_clunk);
14651459

14661460
int p9_client_remove(struct p9_fid *fid)
14671461
{
1468-
int err;
1462+
int err = 0;
14691463
struct p9_client *clnt;
14701464
struct p9_req_t *req;
14711465

14721466
p9_debug(P9_DEBUG_9P, ">>> TREMOVE fid %d\n", fid->fid);
1473-
err = 0;
14741467
clnt = fid->clnt;
14751468

14761469
req = p9_client_rpc(clnt, P9_TREMOVE, "d", fid->fid);
@@ -1680,7 +1673,6 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
16801673
if (!ret)
16811674
return ERR_PTR(-ENOMEM);
16821675

1683-
err = 0;
16841676
clnt = fid->clnt;
16851677

16861678
req = p9_client_rpc(clnt, P9_TSTAT, "d", fid->fid);
@@ -1733,7 +1725,6 @@ struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
17331725
if (!ret)
17341726
return ERR_PTR(-ENOMEM);
17351727

1736-
err = 0;
17371728
clnt = fid->clnt;
17381729

17391730
req = p9_client_rpc(clnt, P9_TGETATTR, "dq", fid->fid, request_mask);
@@ -1812,11 +1803,10 @@ static int p9_client_statsize(struct p9_wstat *wst, int proto_version)
18121803

18131804
int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst)
18141805
{
1815-
int err;
1806+
int err = 0;
18161807
struct p9_req_t *req;
18171808
struct p9_client *clnt;
18181809

1819-
err = 0;
18201810
clnt = fid->clnt;
18211811
wst->size = p9_client_statsize(wst, clnt->proto_version);
18221812
p9_debug(P9_DEBUG_9P, ">>> TWSTAT fid %d\n",
@@ -1851,11 +1841,10 @@ EXPORT_SYMBOL(p9_client_wstat);
18511841

18521842
int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *p9attr)
18531843
{
1854-
int err;
1844+
int err = 0;
18551845
struct p9_req_t *req;
18561846
struct p9_client *clnt;
18571847

1858-
err = 0;
18591848
clnt = fid->clnt;
18601849
p9_debug(P9_DEBUG_9P, ">>> TSETATTR fid %d\n", fid->fid);
18611850
p9_debug(P9_DEBUG_9P, " valid=%x mode=%x uid=%d gid=%d size=%lld\n",
@@ -1887,7 +1876,6 @@ int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb)
18871876
struct p9_req_t *req;
18881877
struct p9_client *clnt;
18891878

1890-
err = 0;
18911879
clnt = fid->clnt;
18921880

18931881
p9_debug(P9_DEBUG_9P, ">>> TSTATFS fid %d\n", fid->fid);
@@ -1921,11 +1909,10 @@ EXPORT_SYMBOL(p9_client_statfs);
19211909
int p9_client_rename(struct p9_fid *fid,
19221910
struct p9_fid *newdirfid, const char *name)
19231911
{
1924-
int err;
1912+
int err = 0;
19251913
struct p9_req_t *req;
19261914
struct p9_client *clnt;
19271915

1928-
err = 0;
19291916
clnt = fid->clnt;
19301917

19311918
p9_debug(P9_DEBUG_9P, ">>> TRENAME fid %d newdirfid %d name %s\n",
@@ -1949,11 +1936,10 @@ EXPORT_SYMBOL(p9_client_rename);
19491936
int p9_client_renameat(struct p9_fid *olddirfid, const char *old_name,
19501937
struct p9_fid *newdirfid, const char *new_name)
19511938
{
1952-
int err;
1939+
int err = 0;
19531940
struct p9_req_t *req;
19541941
struct p9_client *clnt;
19551942

1956-
err = 0;
19571943
clnt = olddirfid->clnt;
19581944

19591945
p9_debug(P9_DEBUG_9P,
@@ -1986,7 +1972,6 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid,
19861972
struct p9_client *clnt;
19871973
struct p9_fid *attr_fid;
19881974

1989-
err = 0;
19901975
clnt = file_fid->clnt;
19911976
attr_fid = p9_fid_create(clnt);
19921977
if (!attr_fid) {
@@ -2027,14 +2012,13 @@ EXPORT_SYMBOL_GPL(p9_client_xattrwalk);
20272012
int p9_client_xattrcreate(struct p9_fid *fid, const char *name,
20282013
u64 attr_size, int flags)
20292014
{
2030-
int err;
2015+
int err = 0;
20312016
struct p9_req_t *req;
20322017
struct p9_client *clnt;
20332018

20342019
p9_debug(P9_DEBUG_9P,
20352020
">>> TXATTRCREATE fid %d name %s size %llu flag %d\n",
20362021
fid->fid, name, attr_size, flags);
2037-
err = 0;
20382022
clnt = fid->clnt;
20392023
req = p9_client_rpc(clnt, P9_TXATTRCREATE, "dsqd",
20402024
fid->fid, name, attr_size, flags);
@@ -2063,7 +2047,6 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset)
20632047
p9_debug(P9_DEBUG_9P, ">>> TREADDIR fid %d offset %llu count %d\n",
20642048
fid->fid, offset, count);
20652049

2066-
err = 0;
20672050
clnt = fid->clnt;
20682051

20692052
rsize = fid->iounit;
@@ -2122,7 +2105,6 @@ int p9_client_mknod_dotl(struct p9_fid *fid, const char *name, int mode,
21222105
struct p9_client *clnt;
21232106
struct p9_req_t *req;
21242107

2125-
err = 0;
21262108
clnt = fid->clnt;
21272109
p9_debug(P9_DEBUG_9P,
21282110
">>> TMKNOD fid %d name %s mode %d major %d minor %d\n",
@@ -2153,7 +2135,6 @@ int p9_client_mkdir_dotl(struct p9_fid *fid, const char *name, int mode,
21532135
struct p9_client *clnt;
21542136
struct p9_req_t *req;
21552137

2156-
err = 0;
21572138
clnt = fid->clnt;
21582139
p9_debug(P9_DEBUG_9P, ">>> TMKDIR fid %d name %s mode %d gid %d\n",
21592140
fid->fid, name, mode, from_kgid(&init_user_ns, gid));
@@ -2182,7 +2163,6 @@ int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status)
21822163
struct p9_client *clnt;
21832164
struct p9_req_t *req;
21842165

2185-
err = 0;
21862166
clnt = fid->clnt;
21872167
p9_debug(P9_DEBUG_9P,
21882168
">>> TLOCK fid %d type %i flags %d start %lld length %lld proc_id %d client_id %s\n",
@@ -2214,7 +2194,6 @@ int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *glock)
22142194
struct p9_client *clnt;
22152195
struct p9_req_t *req;
22162196

2217-
err = 0;
22182197
clnt = fid->clnt;
22192198
p9_debug(P9_DEBUG_9P,
22202199
">>> TGETLOCK fid %d, type %i start %lld length %lld proc_id %d client_id %s\n",
@@ -2251,7 +2230,6 @@ int p9_client_readlink(struct p9_fid *fid, char **target)
22512230
struct p9_client *clnt;
22522231
struct p9_req_t *req;
22532232

2254-
err = 0;
22552233
clnt = fid->clnt;
22562234
p9_debug(P9_DEBUG_9P, ">>> TREADLINK fid %d\n", fid->fid);
22572235

0 commit comments

Comments
 (0)