From: kernel test robot <lkp@intel.com>
To: Damien Le Moal <damien.lemoal@wdc.com>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Dave Chinner <dchinner@redhat.com>
Subject: fs/zonefs/super.c:1110:6: warning: Variable 'ret' is reassigned a value before the old one has been used.
Date: Sun, 19 Jul 2020 10:29:17 +0800 [thread overview]
Message-ID: <202007191013.4IvvVjHl%lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 6cf7ccba29dcf39ab27630c383a3844078a6d5cd
commit: 8dcc1a9d90c10fa4143e5c17821082e5e60e46a1 fs: New zonefs file system
date: 5 months ago
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
cppcheck warnings: (new ones prefixed by >>)
>> fs/zonefs/super.c:1110:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
ret = 0;
^
fs/zonefs/super.c:1045:0: note: Variable 'ret' is reassigned a value before the old one has been used.
int ret = -ENOMEM;
^
fs/zonefs/super.c:1110:6: note: Variable 'ret' is reassigned a value before the old one has been used.
ret = 0;
^
fs/zonefs/super.c:1257:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
ret = 0;
^
fs/zonefs/super.c:1210:6: note: Variable 'ret' is reassigned a value before the old one has been used.
ret = -EINVAL;
^
fs/zonefs/super.c:1257:6: note: Variable 'ret' is reassigned a value before the old one has been used.
ret = 0;
^
vim +/ret +1110 fs/zonefs/super.c
1031
1032 /*
1033 * Create a zone group and populate it with zone files.
1034 */
1035 static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
1036 enum zonefs_ztype type)
1037 {
1038 struct super_block *sb = zd->sb;
1039 struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
1040 struct blk_zone *zone, *next, *end;
1041 const char *zgroup_name;
1042 char *file_name;
1043 struct dentry *dir;
1044 unsigned int n = 0;
1045 int ret = -ENOMEM;
1046
1047 /* If the group is empty, there is nothing to do */
1048 if (!zd->nr_zones[type])
1049 return 0;
1050
1051 file_name = kmalloc(ZONEFS_NAME_MAX, GFP_KERNEL);
1052 if (!file_name)
1053 return -ENOMEM;
1054
1055 if (type == ZONEFS_ZTYPE_CNV)
1056 zgroup_name = "cnv";
1057 else
1058 zgroup_name = "seq";
1059
1060 dir = zonefs_create_inode(sb->s_root, zgroup_name, NULL, type);
1061 if (!dir)
1062 goto free;
1063
1064 /*
1065 * The first zone contains the super block: skip it.
1066 */
1067 end = zd->zones + blkdev_nr_zones(sb->s_bdev->bd_disk);
1068 for (zone = &zd->zones[1]; zone < end; zone = next) {
1069
1070 next = zone + 1;
1071 if (zonefs_zone_type(zone) != type)
1072 continue;
1073
1074 /*
1075 * For conventional zones, contiguous zones can be aggregated
1076 * together to form larger files. Note that this overwrites the
1077 * length of the first zone of the set of contiguous zones
1078 * aggregated together. If one offline or read-only zone is
1079 * found, assume that all zones aggregated have the same
1080 * condition.
1081 */
1082 if (type == ZONEFS_ZTYPE_CNV &&
1083 (sbi->s_features & ZONEFS_F_AGGRCNV)) {
1084 for (; next < end; next++) {
1085 if (zonefs_zone_type(next) != type)
1086 break;
1087 zone->len += next->len;
1088 if (next->cond == BLK_ZONE_COND_READONLY &&
1089 zone->cond != BLK_ZONE_COND_OFFLINE)
1090 zone->cond = BLK_ZONE_COND_READONLY;
1091 else if (next->cond == BLK_ZONE_COND_OFFLINE)
1092 zone->cond = BLK_ZONE_COND_OFFLINE;
1093 }
1094 }
1095
1096 /*
1097 * Use the file number within its group as file name.
1098 */
1099 snprintf(file_name, ZONEFS_NAME_MAX - 1, "%u", n);
1100 if (!zonefs_create_inode(dir, file_name, zone, type))
1101 goto free;
1102
1103 n++;
1104 }
1105
1106 zonefs_info(sb, "Zone group \"%s\" has %u file%s\n",
1107 zgroup_name, n, n > 1 ? "s" : "");
1108
1109 sbi->s_nr_files[type] = n;
> 1110 ret = 0;
1111
1112 free:
1113 kfree(file_name);
1114
1115 return ret;
1116 }
1117
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
next reply other threads:[~2020-07-19 2:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-19 2:29 kernel test robot [this message]
2020-08-09 8:08 fs/zonefs/super.c:1110:6: warning: Variable 'ret' is reassigned a value before the old one has been used kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202007191013.4IvvVjHl%lkp@intel.com \
--to=lkp@intel.com \
--cc=damien.lemoal@wdc.com \
--cc=dchinner@redhat.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).