linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: ldv@altlinux.org
Cc: linux-fsdevel@vger.kernel.org
Subject: re: vfs: make mounts and mountstats honor root dir like mountinfo does
Date: Mon, 10 Aug 2015 15:15:43 +0300	[thread overview]
Message-ID: <20150810121543.GA4359@mwanda> (raw)

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

                 reply	other threads:[~2015-08-10 12:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20150810121543.GA4359@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=ldv@altlinux.org \
    --cc=linux-fsdevel@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).