All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 4/4] Update tests for lvseg apis.
Date: Sun, 24 Oct 2010 18:24:00 +0200	[thread overview]
Message-ID: <4CC45DA0.4030509@redhat.com> (raw)
In-Reply-To: <87lj5q61rn.fsf@twilight.int.mornfall.net.>

Dne 22.10.2010 10:59, Petr Rockai napsal(a):
> Zdenek Kabelac <zkabelac@redhat.com> writes:
>>>> And I think using pointer would be wise decision here.
>>> Care to elaborate? What's wise about using a pointer here?
>>
>> (const struct lvm_proper_value *v)
>>
>> avoid doing local copy of the 'v' structure - currently it's not a big
>> difference, but as you pointed out in other emails - it could be extended in
>> future. And I think we are using  pointers in other calls as well - so we
>> should stay consistent also internally - and just pass pointers all the time -
>> instead of thinking when to use struct and when the pointer should be passed.
> 
> Unlike object lifetime, this is something that the compiler can check
> statically. Moreover, it may or may not be more efficient to pass a
> pointer. Usually it's not, unless the structure is big and/or the
> compiler optimisations poor.
> 
> Passing a value is prone to fewer errors. I vote for a value. (We should
> aim to pass values whenever possible, IMHO. Those vg_t/pv_t/lv_t behave
> as values as well, in this respect.)
> 

I'm not going to argue whether it's more or less efficient as in this case it
will make no difference.  But passing things by value is simply very hardly
supportable by dso libraries - and usually require complete rebuild of binary
to use updated library. Also you would need to remember where are you using
passing by value - and in case structure size grows - rewrite many functions
to switch to pointers - why not do that right from the beginning? -  I'd pass
by value only the language atomic/basic types - definitely not any structure
where even you are pointing out future extensions in other post.

BTW: I don't take vg_t/pv_t/lv_t as an an argument for passing things by value
as it's nothing else that syntactical sugar for pointers - and in fact I'd not
any objections against exactly same strategy for properties - making property
object completely private structure to lvm and give the API user only handle
lvm_property_t and set of function for this handle (C++ in C :))
(i.e.
lvm_property_is_string/get_string/is_integer/get_integer(lvm_property_t...)

Zdenek



  reply	other threads:[~2010-10-24 16:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-19 13:24 [PATCH 00/04] Add lvm lvseg properties for lvm2app Dave Wysochanski
2010-10-19 13:24 ` [PATCH 1/4] Add lvseg_t to lvm2app and lvm_lv_list_lvsegs() Dave Wysochanski
2010-10-19 13:24 ` [PATCH 2/4] Add lvseg 'get' functions Dave Wysochanski
2010-10-20 11:53   ` Zdenek Kabelac
2010-10-21 16:36     ` Petr Rockai
2010-10-19 13:24 ` [PATCH 3/4] Add lvm_lvseg_get_property() function Dave Wysochanski
2010-10-20 11:47   ` Zdenek Kabelac
2010-10-19 13:24 ` [PATCH 4/4] Update tests for lvseg apis Dave Wysochanski
2010-10-20 12:08   ` Zdenek Kabelac
2010-10-21 16:38     ` Petr Rockai
2010-10-22  8:26       ` Zdenek Kabelac
2010-10-22  8:59         ` Petr Rockai
2010-10-24 16:24           ` Zdenek Kabelac [this message]
2010-10-24 21:06             ` Petr Rockai
2010-10-25 13:27               ` Zdenek Kabelac

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=4CC45DA0.4030509@redhat.com \
    --to=zkabelac@redhat.com \
    --cc=lvm-devel@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.