From: Wei Liu <wei.liu2@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Campbell <Ian.Campbell@citrix.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCH V3] xl: create VFB for PV guest when VNC is specified
Date: Tue, 17 Dec 2013 15:16:02 +0000 [thread overview]
Message-ID: <20131217151602.GA6093@zion.uk.xensource.com> (raw)
In-Reply-To: <21168.26479.367333.933990@mariner.uk.xensource.com>
On Tue, Dec 17, 2013 at 03:02:07PM +0000, Ian Jackson wrote:
> Wei Liu writes ("Re: [Xen-devel] [PATCH V3] xl: create VFB for PV guest when VNC is specified"):
> > On Tue, Dec 17, 2013 at 11:41:29AM +0000, Ian Campbell wrote:
> ...
> > > In hindsight its main use is probably in making macros only evaluate
> > > once, so if it itself did the evaluation it wouldn't be very useful!
> >
> > So now the macro becomes:
> >
> > #define ARRAY_EXTEND(ptr,count,ret) \
> > do { \
> > typeof((ptr)) *__ptr = &(ptr); \
> > typeof((count)) *__count = &(count); \
> > *__ptr = xrealloc(*__ptr, \
> > sizeof(**__ptr) * (*__count + 1)); \
> > (ret) = *__ptr + *__count; \
> > (*__count)++; \
> > } while (0)
> >
> > Thoughts?
>
> I think all of this complexity to avoid evaluating the array and count
> arguments more than once is unnecessary. Particularly when they're
> both going to be updated.
>
> But if you are doing to do that, you need to give your local variables
> different names. Firstly: names starting __ are reserved for the C
> implementation and shouldn't be used for anything at all. Secondly,
> prefixing the names with something like "_" isn't sufficient in the
> general case and is the wrong habit. If you need to define a local
> variable in a macro you should decorate it with something related to
> the name of the macro. (Hopefully no-one will invoke the same macro
> in one of its own arguments.)
>
> Please make the macro return the new array entry as Ian C suggested.
>
OK.
> Finally: IMO the macro should probably initialise the new element
> itself. So it will be more than just "ARRAY_EXTEND" because it will
> have some knowledge of the kind of array it is, and might need to be
> renamed. Ian C, what do you think ?
>
Huh? Elements are initialized by different funcitons. You mean I need to
add extra argument to the macro to pass in the initilization function?
Wei.
> Ian.
next prev parent reply other threads:[~2013-12-17 15:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-16 17:39 [PATCH V3] xl: create VFB for PV guest when VNC is specified Wei Liu
2013-12-16 17:46 ` Ian Campbell
2013-12-17 11:28 ` Wei Liu
2013-12-17 11:36 ` Andrew Cooper
2013-12-17 11:40 ` Wei Liu
2013-12-17 11:41 ` Ian Campbell
2013-12-17 11:49 ` Wei Liu
2013-12-17 15:02 ` Ian Jackson
2013-12-17 15:16 ` Wei Liu [this message]
2013-12-17 16:15 ` Ian Jackson
2013-12-17 16:40 ` Ian Campbell
2013-12-17 16:52 ` Wei Liu
2013-12-17 18:04 ` Ian Jackson
2013-12-17 21:51 ` Wei Liu
2013-12-17 14:44 ` Ian Jackson
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=20131217151602.GA6093@zion.uk.xensource.com \
--to=wei.liu2@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xen.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.