[Qemu-devel] Re: [PATCH 1/2] Introduce strtosz_suffix()

2010-12-09 Thread Jes Sorensen
On 12/09/10 13:53, Stefan Hajnoczi wrote:
 On Thu, Dec 09, 2010 at 01:13:33PM +0100, jes.soren...@redhat.com wrote:
 @@ -371,3 +377,8 @@ fail:

  return retval;
  }
 +
 +ssize_t strtosz(const char *nptr, char **end)
 +{
 +return strtosz_suffix(nptr, end, 0);
 
 This obscures what the default is, please use STRTOSZ_DEFSUFFIX_MB.  0
 isn't very meaningful and requires the reader to dig into strtosz().

It doesn't make much different to me, but ok, that is easy to fix.

 diff --git a/qemu-common.h b/qemu-common.h
 index de82c2e..dc44cd6 100644
 --- a/qemu-common.h
 +++ b/qemu-common.h
 @@ -149,7 +149,14 @@ time_t mktimegm(struct tm *tm);
  int qemu_fls(int i);
  int qemu_fdatasync(int fd);
  int fcntl_setfl(int fd, int flag);
 +
 +#define STRTOSZ_DEFSUFFIX_TB'T'
 +#define STRTOSZ_DEFSUFFIX_GB'G'
 +#define STRTOSZ_DEFSUFFIX_MB'M'
 +#define STRTOSZ_DEFSUFFIX_KB'K'
 +#define STRTOSZ_DEFSUFFIX_B 'B'
  ssize_t strtosz(const char *nptr, char **end);
 +ssize_t strtosz_suffix(const char *nptr, char **end, const char);
 
 An argument name would be nice: const char unit?

I'll add that in the same round.

Cheers,
Jes




[Qemu-devel] Re: [PATCH 1/2] Introduce strtosz_suffix()

2010-12-09 Thread Stefan Hajnoczi
On Thu, Dec 09, 2010 at 01:13:33PM +0100, jes.soren...@redhat.com wrote:
 @@ -371,3 +377,8 @@ fail:
 
  return retval;
  }
 +
 +ssize_t strtosz(const char *nptr, char **end)
 +{
 +return strtosz_suffix(nptr, end, 0);

This obscures what the default is, please use STRTOSZ_DEFSUFFIX_MB.  0
isn't very meaningful and requires the reader to dig into strtosz().

 diff --git a/qemu-common.h b/qemu-common.h
 index de82c2e..dc44cd6 100644
 --- a/qemu-common.h
 +++ b/qemu-common.h
 @@ -149,7 +149,14 @@ time_t mktimegm(struct tm *tm);
  int qemu_fls(int i);
  int qemu_fdatasync(int fd);
  int fcntl_setfl(int fd, int flag);
 +
 +#define STRTOSZ_DEFSUFFIX_TB 'T'
 +#define STRTOSZ_DEFSUFFIX_GB 'G'
 +#define STRTOSZ_DEFSUFFIX_MB 'M'
 +#define STRTOSZ_DEFSUFFIX_KB 'K'
 +#define STRTOSZ_DEFSUFFIX_B  'B'
  ssize_t strtosz(const char *nptr, char **end);
 +ssize_t strtosz_suffix(const char *nptr, char **end, const char);

An argument name would be nice: const char unit?

Stefan