All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: mpatocka@redhat.com
Cc: dm-devel@redhat.com
Subject: [bug report] dm: add statistics support
Date: Thu, 15 Mar 2018 17:25:32 +0300	[thread overview]
Message-ID: <20180315142532.GA29284@mwanda> (raw)

[ This code is half a decade old so probably removing the dead code is
  fine?  - dan ]

Hello Mikulas Patocka,

The patch fd2ed4d25270: "dm: add statistics support" from Aug 16,
2013, leads to the following static checker warning:

	drivers/md/dm-stats.c:371 dm_stats_create()
	warn: dead code because of 's->id == ((~0 >> 1))' and 'tmp_s->id < s->id'

drivers/md/dm-stats.c
   361          mutex_lock(&stats->mutex);
   362          s->id = 0;
   363          list_for_each(l, &stats->list) {
   364                  tmp_s = container_of(l, struct dm_stat, list_entry);
   365                  if (WARN_ON(tmp_s->id < s->id)) {
                                    ^^^^^^^^^^^^^^^^^
This condition means that s->id can't be INT_MAX.

   366                          r = -EINVAL;
   367                          goto out_unlock_resume;
   368                  }
   369                  if (tmp_s->id > s->id)
   370                          break;
   371                  if (unlikely(s->id == INT_MAX)) {
                                     ^^^^^^^^^^^^^^^^
So we can probably remove this dead code?  Was something else intended?

   372                          r = -ENFILE;
   373                          goto out_unlock_resume;
   374                  }
   375                  s->id++;
   376          }
   377          ret_id = s->id;
   378          list_add_tail_rcu(&s->list_entry, l);
   379          mutex_unlock(&stats->mutex);
   380  
   381          resume_callback(md);
   382  
   383          return ret_id;
   384  
   385  out_unlock_resume:
   386          mutex_unlock(&stats->mutex);
   387          resume_callback(md);
   388  out:
   389          dm_stat_free(&s->rcu_head);
   390          return r;
   391  }

regards,
dan carpenter

             reply	other threads:[~2018-03-15 14:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 14:25 Dan Carpenter [this message]
2018-03-15 19:25 ` [bug report] dm: add statistics support Mikulas Patocka
2018-03-16 10:52   ` Dan Carpenter
2018-03-16 10:54     ` Dan Carpenter

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=20180315142532.GA29284@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=dm-devel@redhat.com \
    --cc=mpatocka@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.