hail-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: Project Hail <hail-devel@vger.kernel.org>
Subject: [PATCH hail] const-correctness tweaks
Date: Wed, 06 Oct 2010 14:07:01 +0200	[thread overview]
Message-ID: <87mxqro78a.fsf@meyering.net> (raw)


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@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(-)

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

             reply	other threads:[~2010-10-06 12:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-06 12:07 Jim Meyering [this message]
2010-10-07  6:00 ` [PATCH hail] const-correctness tweaks Jeff Garzik
2010-10-07  6:38   ` Jim Meyering
2010-10-19 22:24 ` Jeff Garzik
2010-10-20  8:00   ` Jim Meyering
2010-10-20  8:36     ` Jeff Garzik
2010-10-20  8:53       ` Jim Meyering
2010-10-23  1:49         ` Jeff Garzik
2010-10-23  3:01           ` Jeff Garzik
2010-10-23  6:47           ` Jim Meyering

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=87mxqro78a.fsf@meyering.net \
    --to=jim@meyering.net \
    --cc=hail-devel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).