Skip to contentSkip to conversation

fs/ceph/crypto.c:187:17: sparse: sparse: non size-preserving pointer to integer cast

PATCH kernel test robot 1 participant 1 message Oct 31

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://github.com/ceph/ceph-client.git testing
head:   3f007b9f327745c94aec312a28973b28f6a51fc4
commit: 88d679bc66688124f73a2e30617c12a14bb5aeff [35/47] ceph: convert remaining helper paths to BLOG logging
config: m68k-randconfig-r2300-20261031 (https://download.01.org/0day-ci/archive/20261031/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 8.5.0
sparse: v0.6.5-rc1-21-g84ec0658
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261031/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> fs/ceph/crypto.c:187:17: sparse: sparse: non size-preserving pointer to integer cast

fs/ceph/crypto.c:200:17: sparse: sparse: non size-preserving pointer to integer cast fs/ceph/crypto.c:210:25: sparse: sparse: non size-preserving pointer to integer cast fs/ceph/crypto.c:210:25: sparse: sparse: non size-preserving pointer to integer cast fs/ceph/crypto.c:281:9: sparse: sparse: non size-preserving pointer to integer cast fs/ceph/crypto.c:498:9: sparse: sparse: non size-preserving pointer to integer cast fs/ceph/crypto.c:498:9: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:498:9: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:498:9: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:509:9: sparse: sparse: non size-preserving pointer to integer cast fs/ceph/crypto.c:509:9: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:509:9: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:509:9: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:586:17: sparse: sparse: non size-preserving pointer to integer cast fs/ceph/crypto.c:586:17: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:586:17: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:610:17: sparse: sparse: non size-preserving pointer to integer cast fs/ceph/crypto.c:610:17: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:610:17: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:610:17: sparse: sparse: non size-preserving integer to pointer cast fs/ceph/crypto.c:610:17: sparse: sparse: non size-preserving integer to pointer cast

vim +187 fs/ceph/crypto.c

154
155 /*
156 * User-created snapshots can't start with '_'. Snapshots that start with this
157 * character are special (hint: there aren't real snapshots) and use the
158 * following format:
159 *
160 * _<SNAPSHOT-NAME>_<INODE-NUMBER>
161 *
162 * where:
163 * - <SNAPSHOT-NAME> - the real snapshot name that may need to be decrypted,
164 * - <INODE-NUMBER> - the inode number (in decimal) for the actual snapshot
165 *
166 * This function parses these snapshot names and returns the inode
167 * <INODE-NUMBER>. 'name_len' will also bet set with the <SNAPSHOT-NAME>
168 * length.
169 */
170 static struct inode *parse_longname(const struct inode *parent,
171 const char *name, int *name_len)
172 {
173 struct ceph_client *cl = ceph_inode_to_client(parent);
174 struct inode *dir = NULL;
175 struct ceph_vino vino = { .snap = CEPH_NOSNAP };
176 char *name_end, *inode_number;
177 int ret = -EIO;
178 /* Snapshot name must start with an underscore */
179 if (*name_len <= 0 || name[0] != '_')
180 return ERR_PTR(-EIO);
181 /* Skip initial '_' and NUL-terminate */
182 char *str __free(kfree) = kmemdup_nul(name + 1, *name_len - 1, GFP_KERNEL);
183 if (!str)
184 return ERR_PTR(-ENOMEM);
185 name_end = strrchr(str, '_');
186 if (!name_end) {

 > 187			boutc(cl, "failed to parse long snapshot name: %s\n", str);

188 return ERR_PTR(-EIO);
189 }
190 *name_len = (name_end - str);
191 if (*name_len <= 0) {
192 pr_err_client(cl, "failed to parse long snapshot name\n");
193 return ERR_PTR(-EIO);
194 }
195
196 /* Get the inode number */
197 inode_number = name_end + 1;
198 ret = kstrtou64(inode_number, 10, &vino.ino);
199 if (ret) {
200 boutc(cl, "failed to parse inode number: %s\n", str);
201 return ERR_PTR(ret);
202 }
203
204 /* And finally the inode */
205 dir = ceph_find_inode(parent->i_sb, vino);
206 if (!dir) {
207 /* This can happen if we're not mounting cephfs on the root */
208 dir = ceph_get_inode(parent->i_sb, vino, NULL);
209 if (IS_ERR(dir))
210 boutc(cl, "can't find inode %s (_%s)\n", inode_number, str);
211 }
212 return dir;
213 }
214

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki