All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com,
	qemu-devel@nongnu.org, stefanha@gmail.com
Subject: Re: [Qemu-devel] [PATCH 4/6] libqblock internal used functions
Date: Mon, 03 Sep 2012 08:28:38 -0600	[thread overview]
Message-ID: <5044BE96.7080701@redhat.com> (raw)
In-Reply-To: <1346663926-20188-5-git-send-email-xiawenc@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2177 bytes --]

On 09/03/2012 03:18 AM, Wenchao Xia wrote:
>   This patch contains internal helper codes.
> 
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
>  block.c                      |    2 +-
>  block.h                      |    1 +
>  libqblock/libqblock-helper.c |   92 ++++++++++++++++++++++++++++++++++++++++++
>  libqblock/libqblock-helper.h |   57 ++++++++++++++++++++++++++
>  4 files changed, 151 insertions(+), 1 deletions(-)
>  create mode 100644 libqblock/libqblock-helper.c
>  create mode 100644 libqblock/libqblock-helper.h
> 

> +++ b/libqblock/libqblock-helper.c
> @@ -0,0 +1,92 @@
> +#include "libqblock-helper.h"

No copyright.  Shame.  I'll quit pointing it out for the rest of the series.

> +++ b/libqblock/libqblock-helper.h

> +
> +/* this file contains helper function used internally. */
> +#define SECTOR_SIZE (512)

Hard-coding this feels wrong, in this day and age of disks with 4096
sectors.  Why isn't this a per-image property?

> +#define SECTOR_SIZE_MASK (0x01ff)
> +#define SECTOR_SIZE_BITS_NUM (9)

and these computed from a dynamic per-image sector size?

> +#define FUNC_FREE free
> +#define FUNC_MALLOC malloc
> +#define FUNC_CALLOC calloc

Is libqblock-helper.h intended to be installed and included in client
applications, or is it internal only?  If clients can ever use this
header, then you need to avoid namespace violations, by using naming
such as QB_SECTOR_SIZE, QB_FUNC_FREE, and so forth.

> +
> +const char *fmt2str(enum QBlockFormat fmt);
> +enum QBlockFormat str2fmt(const char *fmt);

Even if this header is not intended for clients, you STILL need to avoid
namespace pollution, by either ensuring that your library marks
visibility annotations to avoid exporting symbols outside of the public
namespace, or by renaming even your internal functions to comply with
the namespace.  In other words, stomping on the name 'fmt2str' and
'str2fmt' as an external function name is just too likely to clash with
an arbitrary client linking against your library.

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 617 bytes --]

  parent reply	other threads:[~2012-09-03 14:29 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-03  9:18 [Qemu-devel] [PATCH 0/6] libqblock, qemu block layer library Wenchao Xia
2012-09-03  9:18 ` [Qemu-devel] [PATCH 1/6] libqblock APIs Wenchao Xia
2012-09-03 13:18   ` Paolo Bonzini
2012-09-04  3:15     ` Wenchao Xia
2012-09-04  6:50       ` Paolo Bonzini
2012-09-04  9:05         ` Wenchao Xia
2012-09-10  8:10         ` Wenchao Xia
2012-09-03 13:56   ` Eric Blake
2012-09-03 14:05     ` Paolo Bonzini
2012-09-04  7:05       ` Wenchao Xia
2012-09-04  7:29         ` Paolo Bonzini
2012-09-04  6:42     ` Wenchao Xia
2012-09-04 11:35       ` Eric Blake
2012-09-04 13:47         ` Paolo Bonzini
2012-09-03 19:22   ` Blue Swirl
2012-09-03  9:18 ` [Qemu-devel] [PATCH 2/6] libqblock public type defines Wenchao Xia
2012-09-03 13:13   ` Paolo Bonzini
2012-09-04  2:00     ` Wenchao Xia
2012-09-03 14:20   ` Eric Blake
2012-09-04  7:10     ` Wenchao Xia
2012-09-04  7:37       ` Paolo Bonzini
2012-09-03 19:31   ` Blue Swirl
2012-09-04  7:19     ` Wenchao Xia
2012-09-04  7:38       ` Paolo Bonzini
2012-09-04 19:22         ` Blue Swirl
2012-09-10  8:22           ` Wenchao Xia
2012-09-03  9:18 ` [Qemu-devel] [PATCH 3/6] libqblock error handling Wenchao Xia
2012-09-03 14:22   ` Eric Blake
2012-09-04  7:12     ` Wenchao Xia
2012-09-10  8:20     ` Wenchao Xia
2012-09-03  9:18 ` [Qemu-devel] [PATCH 4/6] libqblock internal used functions Wenchao Xia
2012-09-03 13:18   ` Paolo Bonzini
2012-09-04  3:19     ` Wenchao Xia
2012-09-03 14:28   ` Eric Blake [this message]
2012-09-03 15:18     ` Paolo Bonzini
2012-09-04  7:15       ` Wenchao Xia
2012-09-04  7:38         ` Paolo Bonzini
2012-09-04 11:38         ` Eric Blake
2012-09-04 13:49           ` Paolo Bonzini
2012-09-04 13:51             ` Kevin Wolf
2012-09-10  8:23               ` Wenchao Xia
2012-09-03  9:18 ` [Qemu-devel] [PATCH 5/6] libqblock test example Wenchao Xia
2012-09-03 19:27   ` Blue Swirl
2012-09-03  9:18 ` [Qemu-devel] [PATCH 6/6] libqblock building system Wenchao Xia
2012-09-03 13:10   ` [Qemu-devel] xbzrle migration cache size advise for high memory changes workload ? Alexandre DERUMIER
2012-09-04 14:05     ` Orit Wasserman

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=5044BE96.7080701@redhat.com \
    --to=eblake@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=xiawenc@linux.vnet.ibm.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.