All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] staging: add Lustre file system client support
Date: Thu, 17 Mar 2016 23:09:44 +0300	[thread overview]
Message-ID: <20160317200944.GA25388@mwanda> (raw)

Hello Peng Tao,

The patch d7e09d0397e8: "staging: add Lustre file system client
support" from May 2, 2013, leads to the following static checker
warning:

	drivers/staging/lustre/lustre/obdecho/echo_client.c:1040 cl_echo_enqueue0()
	error: 'lck' dereferencing possible ERR_PTR()

drivers/staging/lustre/lustre/obdecho/echo_client.c
  1034  
  1035          lck = cl_lock_request(env, io, descr, "ec enqueue", eco);
                      ^^^^^^^^^^^^^^^
This can return either an ERR_PTR or NULL.  It's not clear from the
documentation what that means.  There is actually some documentation
for this function though so that's good.


  1036          if (lck) {
                    ^^^
Ugh.  Success handling.

  1037                  struct echo_client_obd *ec = eco->eo_dev->ed_ec;
  1038                  struct echo_lock *el;
  1039  
  1040                  rc = cl_wait(env, lck);
  1041                  if (rc == 0) {
                            ^^^^^^^
More success handling and nested indents.  If we flip these around to
test for failure instead the code becomes much clearer.

  1042                          el = cl2echo_lock(cl_lock_at(lck, &echo_device_type));
  1043                          spin_lock(&ec->ec_lock);
  1044                          if (list_empty(&el->el_chain)) {
  1045                                  list_add(&el->el_chain, &ec->ec_locks);
  1046                                  el->el_cookie = ++ec->ec_unique;
  1047                          }
  1048                          atomic_inc(&el->el_refcount);
  1049                          *cookie = el->el_cookie;
  1050                          spin_unlock(&ec->ec_lock);
  1051                  } else {
  1052                          cl_lock_release(env, lck, "ec enqueue", current);
  1053                  }
  1054          }
  1055          return rc;
  1056  }

regards,
dan carpenter

             reply	other threads:[~2016-03-17 20:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 20:09 Dan Carpenter [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-04-27 12:28 [lustre-devel] staging: add Lustre file system client support Dan Carpenter
2016-05-11 23:53 ` James Simmons
2016-05-13 16:18 ` Drokin, Oleg
2015-10-15 11:14 Dan Carpenter
2015-10-15 11:38 ` Dan Carpenter
2015-10-15 11:43   ` Dan Carpenter
2015-10-15 10:59 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=20160317200944.GA25388@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=lustre-devel@lists.lustre.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 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.