vfs: make mounts and mountstats honor root dir like mountinfo does
Hello Dmitry V. Levin,
The patch 9d4d65748a5c: "vfs: make mounts and mountstats honor root dir like mountinfo does" from Dec 16, 2014, leads to the following static checker warning:
fs/proc_namespace.c:223 show_vfsstat() warn: we tested 'err' before and it was 'false'
fs/proc_namespace.c
188 static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) 189 {
190 struct proc_mounts *p = m->private;
191 struct mount *r = real_mount(mnt);
192 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
193 struct super_block *sb = mnt_path.dentry->d_sb;
194 int err = 0;
195
196 /* device */
197 if (sb->s_op->show_devname) {
198 seq_puts(m, "device ");
199 err = sb->s_op->show_devname(m, mnt_path.dentry);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Do we care if this fails?
200 } else {
201 if (r->mnt_devname) {
202 seq_puts(m, "device ");
203 mangle(m, r->mnt_devname);
204 } else
205 seq_puts(m, "no device");
206 }
207
208 /* mount point */
209 seq_puts(m, " mounted on ");
210 /* mountpoints outside of chroot jail will give SEQ_SKIP on this */
211 err = seq_path_root(m, &mnt_path, &p->root, " \t\n\\");
212 if (err)
213 goto out;We over-write it here.
214 seq_putc(m, ' ');
215
216 /* file system type */
217 seq_puts(m, "with fstype ");
218 show_type(m, sb);
219
220 /* optional statistics */
221 if (sb->s_op->show_stats) {
222 seq_putc(m, ' ');
223 if (!err)
224 err = sb->s_op->show_stats(m, mnt_path.dentry);So we get a static checker warning because the "if (!err)" check is not needed.
225 } 226 227 seq_putc(m, '\n'); 228 out: 229 return err; 230 }
regards,
dan carpenter