[PATCH hail] const-correctness tweaks
- Subject: [PATCH hail] const-correctness tweaks
- From: Jim Meyering <jim@xxxxxxxxxxxx>
- Date: Wed, 06 Oct 2010 14:07:01 +0200
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 Meyering <meyering@xxxxxxxxxx>
---
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(-)
diff --git a/include/hstor.h b/include/hstor.h
index 8620d3b..b47387b 100644
--- a/include/hstor.h
+++ b/include/hstor.h
@@ -132,7 +132,7 @@ enum ReqACLC {
/* hutil.c */
extern char *hutil_time2str(char *buf, int len, time_t time);
extern time_t hutil_str2time(const char *timestr);
-extern int hreq_hdr_push(struct http_req *req, char *key, char *val);
+extern int hreq_hdr_push(struct http_req *req, const char *key, const char *val);
extern char *hreq_hdr(struct http_req *req, const char *key);
extern void hreq_sign(struct http_req *req, const char *bucket, const char *key,
char *b64hmac_out);
@@ -171,7 +171,7 @@ extern bool hstor_del_bucket(struct hstor_client *hstor, const char *name);
extern struct hstor_blist *hstor_list_buckets(struct hstor_client *hstor);
extern bool hstor_get(struct hstor_client *hstor, const char *bucket, const char *key,
- size_t (*write_cb)(void *, size_t, size_t, void *),
+ size_t (*write_cb)(const void *, size_t, size_t, void *),
void *user_data, bool want_headers);
extern void *hstor_get_inline(struct hstor_client *hstor, const char *bucket,
const char *key, bool want_headers, size_t *len);
diff --git a/lib/hstor.c b/lib/hstor.c
index d0d87c7..7f638ec 100644
--- a/lib/hstor.c
+++ b/lib/hstor.c
@@ -86,7 +86,8 @@ err_out:
return NULL;
}
-static size_t all_data_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
+static size_t all_data_cb(const void *ptr, size_t size, size_t nmemb,
+ void *user_data)
{
GByteArray *all_data = user_data;
int len = size * nmemb;
@@ -378,7 +379,7 @@ bool hstor_del_bucket(struct hstor_client *hstor, const char *name)
}
bool hstor_get(struct hstor_client *hstor, const char *bucket, const char *key,
- size_t (*write_cb)(void *, size_t, size_t, void *),
+ size_t (*write_cb)(const void *, size_t, size_t, void *),
void *user_data, bool want_headers)
{
struct http_req req;
diff --git a/lib/hutil.c b/lib/hutil.c
index 7439d52..13a8d5e 100644
--- a/lib/hutil.c
+++ b/lib/hutil.c
@@ -131,7 +131,7 @@ static void cust_fin(struct custom_hdr_vec *cv)
/*
*/
-int hreq_hdr_push(struct http_req *req, char *key, char *val)
+int hreq_hdr_push(struct http_req *req, const char *key, const char *val)
{
struct http_hdr *hdr;
--
1.7.3.1.50.g1e633
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux USB Devel]
[Video for Linux]
[Linux Audio Users]
[Photo]
[Yosemite News]
[Yosemite Photos]
[Free Online Dating]
[Linux Kernel]
[Linux SCSI]
[XFree86]