All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Stephen Hemminger <shemminger@vyatta.com>,
	Wanlong Gao <gaowanlong@cn.fujitsu.com>
Cc: mst@redhat.com, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 1/3] virtio: change to_vp_device to an inlined definition
Date: Thu, 06 Dec 2012 09:58:57 +1030	[thread overview]
Message-ID: <87vccgf58m.fsf@rustcorp.com.au> (raw)
In-Reply-To: <20121205142821.1fb08cf0@samsung-9>

Stephen Hemminger <shemminger@vyatta.com> writes:

> On Wed, 5 Dec 2012 15:03:27 +0800
> Wanlong Gao <gaowanlong@cn.fujitsu.com> wrote:
>
>> to_vp_device is worth changing to inlined definition.
>> 
>> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
>> ---
>>  drivers/virtio/virtio_pci.c | 6 +-----
>>  1 file changed, 1 insertion(+), 5 deletions(-)
>> 
>> diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
>> index e3ecc94..7681fe3 100644
>> --- a/drivers/virtio/virtio_pci.c
>> +++ b/drivers/virtio/virtio_pci.c
>> @@ -98,11 +98,7 @@ static struct pci_device_id virtio_pci_id_table[] = {
>>  
>>  MODULE_DEVICE_TABLE(pci, virtio_pci_id_table);
>>  
>> -/* Convert a generic virtio device to our structure */
>> -static struct virtio_pci_device *to_vp_device(struct virtio_device *vdev)
>> -{
>> -	return container_of(vdev, struct virtio_pci_device, vdev);
>> -}
>> +#define to_vp_device(_vdev) container_of(_vdev, struct virtio_pci_device, vdev)
>
> Just mark the function as inline. A macro loses type checking.

No, don't.

Inline functions in C files are *wrong*: you lose the warning should it
ever become unused.  GCC's does a pretty good job these days: certainly
better than guessing.

(Yeah yeah, there are always exceptions.  I've used inline deliberately
to avoid a tangle of #ifdefs, and sometimes gcc really does screw up).

Thanks,
Rusty.

  reply	other threads:[~2012-12-05 23:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05  7:03 [PATCH 1/3] virtio: change to_vp_device to an inlined definition Wanlong Gao
2012-12-05  7:03 ` [PATCH 2/3] virtio: use dev_to_virtio wrapper in virtio Wanlong Gao
2012-12-05 11:16   ` Michael S. Tsirkin
2012-12-05 11:17     ` Michael S. Tsirkin
2012-12-05 12:59     ` Wanlong Gao
2012-12-05  7:03 ` [PATCH 3/3] virtio: add drv_to_virtio to make code clearly Wanlong Gao
2012-12-05 11:17   ` Michael S. Tsirkin
2012-12-05 11:25 ` [PATCH 1/3] virtio: change to_vp_device to an inlined definition Michael S. Tsirkin
2012-12-05 13:28   ` [PATCH V2 1/2] virtio: use dev_to_virtio wrapper in virtio Wanlong Gao
2012-12-05 13:28     ` [PATCH V2 2/2] virtio: add drv_to_virtio to make code clearly Wanlong Gao
2012-12-05 22:28 ` [PATCH 1/3] virtio: change to_vp_device to an inlined definition Stephen Hemminger
2012-12-05 23:28   ` Rusty Russell [this message]
2012-12-05 23:21 ` Rusty Russell
2012-12-06  6:10   ` Wanlong Gao

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=87vccgf58m.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=mst@redhat.com \
    --cc=shemminger@vyatta.com \
    --cc=virtualization@lists.linux-foundation.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.