Re: [PATCH hail] const-correctness tweaks

2010-10-07 Thread Jeff Garzik

On 10/06/2010 08:07 AM, Jim Meyering wrote:


Make write_cb callback's buffer parameter const, like all write-like
functions.
Give a few char * parameters the const attribute.

Signed-off-by: Jim Meyeringmeyer...@redhat.com
---

It looks like most of hail's interfaces are const-correct,
but one stood out because it provokes a warning when I tried to
pass a const-correct write_cb function to hstor_get from iwhd:

 proxy.c:382: warning: passing argument 4 of 'hstor_get' from \
   incompatible pointer type
 /usr/include/hstor.h:173: note: expected \
   'size_t (*)(void *, size_t, size_t,  void *)' but argument is of type \
   'size_t (*)(const void *, size_t,  size_t,  void *)'

In case you feel comfortable fixing this, here's a patch:


  include/hstor.h |4 ++--
  lib/hstor.c |5 +++--
  lib/hutil.c |2 +-
  3 files changed, 6 insertions(+), 5 deletions(-)


This requires updating test/large-object.c in tabled, too.  Would you 
mind sending along that companion patch?



--
To unsubscribe from this list: send the line unsubscribe hail-devel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH hail] const-correctness tweaks

2010-10-07 Thread Jim Meyering
Jeff Garzik wrote:
 On 10/06/2010 08:07 AM, Jim Meyering wrote:
...
 It looks like most of hail's interfaces are const-correct,
 but one stood out because it provokes a warning when I tried to
 pass a const-correct write_cb function to hstor_get from iwhd:
...
   include/hstor.h |4 ++--
   lib/hstor.c |5 +++--
   lib/hutil.c |2 +-
   3 files changed, 6 insertions(+), 5 deletions(-)

 This requires updating test/large-object.c in tabled, too.  Would you
 mind sending along that companion patch?

Sure.  Posting separately.
With only one use, the tendrils were relatively short.
--
To unsubscribe from this list: send the line unsubscribe hail-devel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH tabled] adapt to changed signature of hstor_get's callback function

2010-10-07 Thread Jim Meyering

* test/large-object.c: Hail has changed hstor_get's callback function
so that it now declares its buffer to be const, as all write-like
functions do.  Adjust this file's hstor_get callback parameter and
propagate that, as required, to the local functions it uses to operate
on that now-read-only buffer.

Signed-off-by: Jim Meyering meyer...@redhat.com
---
 test/large-object.c |9 +
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/test/large-object.c b/test/large-object.c
index dbe2027..fc7d03c 100644
--- a/test/large-object.c
+++ b/test/large-object.c
@@ -1,6 +1,6 @@

 /*
- * Copyright 2008-2009 Red Hat, Inc.
+ * Copyright 2008-2010 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -60,7 +60,7 @@ static char key[] = Key of Large Object;

 #define CSUM_INIT  0x

-static void incrsum(unsigned int *psum, unsigned char *data, size_t len)
+static void incrsum(unsigned int *psum, const unsigned char *data, size_t len)
 {
unsigned int sum;

@@ -108,7 +108,7 @@ static size_t put_cb(void *ptr, size_t membsize, size_t 
nmemb, void *user_data)
return rem;
 }

-static size_t get_one(struct get_ctx *ctx, unsigned char *data, size_t len)
+static size_t get_one(struct get_ctx *ctx, const unsigned char *data, size_t 
len)
 {
unsigned num;
size_t rem;
@@ -143,7 +143,8 @@ static size_t get_one(struct get_ctx *ctx, unsigned char 
*data, size_t len)
return rem;
 }

-static size_t get_cb(void *ptr, size_t membsize, size_t nmemb, void *user_data)
+static size_t get_cb(const void *ptr, size_t membsize, size_t nmemb,
+void *user_data)
 {
struct get_ctx *ctx = user_data;
size_t togo, len;
--
1.7.3.1.50.g1e633
--
To unsubscribe from this list: send the line unsubscribe hail-devel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html