Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1278160

Re: block-rbd: One function call less in rbd_dev_probe_parent() after error detection

From Ilya Dryomov <idryomov@gmail.com>
Newsgroups linux.kernel
Subject Re: block-rbd: One function call less in rbd_dev_probe_parent() after error detection
Date 2015-11-26 12:50 +0100
Message-ID <qz3dM-4z2-15@gated-at.bofh.it> (permalink)
References (16 earlier) <qy5hE-6fV-27@gated-at.bofh.it> <qylPs-cQ-25@gated-at.bofh.it> <qyrrQ-3TV-7@gated-at.bofh.it> <qysnT-4vl-3@gated-at.bofh.it> <qyZDc-1YS-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Nov 26, 2015 at 8:54 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> I interpreted the eventual passing of a null pointer to the rbd_dev_destroy()
>>> function as an indication for further source code adjustments.
>>
>> If all error paths could be adjusted so that NULL pointers are never passed in,
>> destroy functions wouldn't need to have a NULL check, would they?
>
> How do you think about to clarify corresponding implementation details a bit more?
>
> * Why was the function "rbd_dev_probe_parent" implemented in the way
>   that it relies on a sanity check in the function "rbd_dev_destroy" then?

Because it's not a bad thing?  What's wrong with an init to NULL,
a possible assignment, in this case from rbd_dev_create(), and an
unconditional rbd_dev_destroy()?

The NULL check in rbd_dev_destroy() is not a sanity check, it's
a feature.  It's not there to "fixup" callers that pass NULL - it's
there because it is _expected_ that some callers will pass NULL.

> * How are the chances to restructure the source code a bit (like changing a few
>   jump labels) so that it should also work without an extra function call
>   during error handling there?

As I said in my reply to Dan, the problem with rbd_dev_probe_parent()
is the calling code which expects it to call unparent if ->parent_spec.
This makes it stand out and confuses people, but can't be fixed without
refactoring a bunch of other code.

The extra function call is *not* a problem.

Thanks,

                Ilya
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] block-rbd: Deletion of an unnecessary check SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-23 20:50 +0100
  [PATCH 1/2] block-rbd: Delete an unnecessary check before the  function call "rbd_dev_destroy" SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-23 20:50 +0100
    Re: [PATCH 1/2] block-rbd: Delete an unnecessary check before the  function call "rbd_dev_destroy" Ilya Dryomov <idryomov@gmail.com> - 2015-11-24 14:30 +0100
  [PATCH 2/2] block-rbd: One function call less in  rbd_dev_probe_parent() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-23 20:50 +0100
    Re: [PATCH 2/2] block-rbd: One function call less in  rbd_dev_probe_parent() after error detection Ilya Dryomov <idryomov@gmail.com> - 2015-11-24 14:30 +0100
      Re: [PATCH 2/2] block-rbd: One function call less in  rbd_dev_probe_parent() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-24 20:30 +0100
        Re: [PATCH 2/2] block-rbd: One function call less in  rbd_dev_probe_parent() after error detection Ilya Dryomov <idryomov@gmail.com> - 2015-11-24 21:30 +0100
          Re: block-rbd: One function call less in rbd_dev_probe_parent() after  error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-24 21:40 +0100
            Re: block-rbd: One function call less in rbd_dev_probe_parent() after  error detection Ilya Dryomov <idryomov@gmail.com> - 2015-11-24 23:00 +0100
              Re: block-rbd: One function call less in rbd_dev_probe_parent() after  error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-25 11:30 +0100
          Re: [PATCH 2/2] block-rbd: One function call less in  rbd_dev_probe_parent() after error detection Dan Carpenter <dan.carpenter@oracle.com> - 2015-11-25 13:00 +0100
            Re: [PATCH 2/2] block-rbd: One function call less in  rbd_dev_probe_parent() after error detection Ilya Dryomov <idryomov@gmail.com> - 2015-11-25 15:10 +0100
              Re: [PATCH 2/2] block-rbd: One function call less in  rbd_dev_probe_parent() after error detection Dan Carpenter <dan.carpenter@oracle.com> - 2015-11-25 16:30 +0100
          Re: block-rbd: One function call less in rbd_dev_probe_parent() after  error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-26 09:00 +0100
            Re: block-rbd: One function call less in rbd_dev_probe_parent() after  error detection Ilya Dryomov <idryomov@gmail.com> - 2015-11-26 12:50 +0100
              Re: block-rbd: One function call less in rbd_dev_probe_parent() after  error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2015-11-26 14:50 +0100

csiph-web