Skip to content

Commit 01b2651

Browse files
committed
zonefs: Fix compilation warning
Avoid the compilation warning "Variable 'ret' is reassigned a value before the old one has been used." in zonefs_create_zgroup() by setting ret for the error path only if an error happens. Reported-by: kernel test robot <[email protected]> Signed-off-by: Damien Le Moal <[email protected]>
1 parent 5714ee5 commit 01b2651

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fs/zonefs/super.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
11191119
char *file_name;
11201120
struct dentry *dir;
11211121
unsigned int n = 0;
1122-
int ret = -ENOMEM;
1122+
int ret;
11231123

11241124
/* If the group is empty, there is nothing to do */
11251125
if (!zd->nr_zones[type])
@@ -1135,8 +1135,10 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
11351135
zgroup_name = "seq";
11361136

11371137
dir = zonefs_create_inode(sb->s_root, zgroup_name, NULL, type);
1138-
if (!dir)
1138+
if (!dir) {
1139+
ret = -ENOMEM;
11391140
goto free;
1141+
}
11401142

11411143
/*
11421144
* The first zone contains the super block: skip it.
@@ -1174,8 +1176,10 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
11741176
* Use the file number within its group as file name.
11751177
*/
11761178
snprintf(file_name, ZONEFS_NAME_MAX - 1, "%u", n);
1177-
if (!zonefs_create_inode(dir, file_name, zone, type))
1179+
if (!zonefs_create_inode(dir, file_name, zone, type)) {
1180+
ret = -ENOMEM;
11781181
goto free;
1182+
}
11791183

11801184
n++;
11811185
}

0 commit comments

Comments
 (0)