No functional changes, just removed warnings.

* hash.c/hash.h: Removed 'discards const qualifier' warnings
  warc.c/warc.h: Likewise
  http.c: Likewise
  url.c: Likewise

Tim
From 97ddd2fd1ee9e48fd70608893dfa14d7f4e4f4ec Mon Sep 17 00:00:00 2001
From: Tim Ruehsen <[email protected]>
Date: Mon, 14 May 2012 17:32:55 +0200
Subject: [PATCH] * removed 'const' warnings

---
 src/hash.c |    6 +++---
 src/hash.h |    2 +-
 src/http.c |   14 +++++++-------
 src/url.c  |    2 +-
 src/warc.c |   12 ++++++------
 src/warc.h |    2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/hash.c b/src/hash.c
index 6c40801..129ead1 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -423,14 +423,14 @@ grow_hash_table (struct hash_table *ht)
    table if necessary.  */
 
 void
-hash_table_put (struct hash_table *ht, const void *key, void *value)
+hash_table_put (struct hash_table *ht, const void *key, const void *value)
 {
   struct cell *c = find_cell (ht, key);
   if (CELL_OCCUPIED (c))
     {
       /* update existing item */
       c->key   = (void *)key; /* const? */
-      c->value = value;
+      c->value = (void *)value;
       return;
     }
 
@@ -445,7 +445,7 @@ hash_table_put (struct hash_table *ht, const void *key, void *value)
   /* add new item */
   ++ht->count;
   c->key   = (void *)key;       /* const? */
-  c->value = value;
+  c->value = (void *)value;
 }
 
 /* Remove KEY->value mapping from HT.  Return 0 if there was no such
diff --git a/src/hash.h b/src/hash.h
index 1dadf09..8576760 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -42,7 +42,7 @@ int hash_table_get_pair (const struct hash_table *, const void *,
                          void *, void *);
 int hash_table_contains (const struct hash_table *, const void *);
 
-void hash_table_put (struct hash_table *, const void *, void *);
+void hash_table_put (struct hash_table *, const void *, const void *);
 int hash_table_remove (struct hash_table *, const void *);
 void hash_table_clear (struct hash_table *);
 
diff --git a/src/http.c b/src/http.c
index cf90192..8d4edba 100644
--- a/src/http.c
+++ b/src/http.c
@@ -231,7 +231,7 @@ release_header (struct request_header *hdr)
    */
 
 static void
-request_set_header (struct request *req, char *name, char *value,
+request_set_header (struct request *req, const char *name, const char *value,
                     enum rp release_policy)
 {
   struct request_header *hdr;
@@ -242,7 +242,7 @@ request_set_header (struct request *req, char *name, char *value,
       /* A NULL value is a no-op; if freeing the name is requested,
          free it now to avoid leaks.  */
       if (release_policy == rel_name || release_policy == rel_both)
-        xfree (name);
+        xfree ((void *)name);
       return;
     }
 
@@ -253,8 +253,8 @@ request_set_header (struct request *req, char *name, char *value,
         {
           /* Replace existing header. */
           release_header (hdr);
-          hdr->name = name;
-          hdr->value = value;
+          hdr->name = (void *)name;
+          hdr->value = (void *)value;
           hdr->release_policy = release_policy;
           return;
         }
@@ -268,8 +268,8 @@ request_set_header (struct request *req, char *name, char *value,
       req->headers = xrealloc (req->headers, req->hcapacity * sizeof (*hdr));
     }
   hdr = &req->headers[req->hcount++];
-  hdr->name = name;
-  hdr->value = value;
+  hdr->name = (void *)name;
+  hdr->value = (void *)value;
   hdr->release_policy = release_policy;
 }
 
@@ -296,7 +296,7 @@ request_set_user_header (struct request *req, const char *header)
    the header was actually removed, false otherwise.  */
 
 static bool
-request_remove_header (struct request *req, char *name)
+request_remove_header (struct request *req, const char *name)
 {
   int i;
   for (i = 0; i < req->hcount; i++)
diff --git a/src/url.c b/src/url.c
index ddde798..e44dfcd 100644
--- a/src/url.c
+++ b/src/url.c
@@ -1504,7 +1504,7 @@ url_file_name (const struct url *u, char *replaced_filename)
 
   const char *u_file;
   char *fname, *unique;
-  char *index_filename = "index.html"; /* The default index file is index.html */
+  const char *index_filename = "index.html"; /* The default index file is index.html */
 
   fnres.base = NULL;
   fnres.size = 0;
diff --git a/src/warc.c b/src/warc.c
index fa0830d..a2cf102 100644
--- a/src/warc.c
+++ b/src/warc.c
@@ -372,7 +372,7 @@ warc_write_end_record (void)
    the current WARC record.
    If timestamp is NULL, the current time will be used.  */
 static bool
-warc_write_date_header (char *timestamp)
+warc_write_date_header (const char *timestamp)
 {
   if (timestamp == NULL)
     {
@@ -725,9 +725,9 @@ warc_start_new_file (bool meta)
   warc_current_filename = new_filename;
 
 #ifdef HAVE_LIBZ
-  char *extension = (opt.warc_compression_enabled ? "warc.gz" : "warc");
+  const char *extension = (opt.warc_compression_enabled ? "warc.gz" : "warc");
 #else
-  char *extension = "warc";
+  const char *extension = "warc";
 #endif
 
   /* If max size is enabled, we add a serial number to the file names. */
@@ -1166,7 +1166,7 @@ warc_write_request_record (char *url, char *timestamp_str, char *record_uuid, ip
    response_uuid  is the uuid of the response.
    Returns true on success, false on error. */
 static bool
-warc_write_cdx_record (char *url, char *timestamp_str, char *mime_type, int response_code, char *payload_digest, char *redirect_location, off_t offset, char *warc_filename, char *response_uuid)
+warc_write_cdx_record (const char *url, const char *timestamp_str, const char *mime_type, int response_code, const char *payload_digest, const char *redirect_location, off_t offset, const char *warc_filename, const char *response_uuid)
 {
   /* Transform the timestamp. */
   char timestamp_str_cdx [15];
@@ -1179,7 +1179,7 @@ warc_write_cdx_record (char *url, char *timestamp_str, char *mime_type, int resp
   timestamp_str_cdx[14] = '\0';
   
   /* Rewrite the checksum. */
-  char *checksum;
+  const char *checksum;
   if (payload_digest != NULL)
     checksum = payload_digest + 5; /* Skip the "sha1:" */
   else
@@ -1349,7 +1349,7 @@ warc_write_response_record (char *url, char *timestamp_str, char *concurrent_to_
    Calling this function will close body.
    Returns true on success, false on error. */
 bool
-warc_write_resource_record (char *resource_uuid, char *url, char *timestamp_str, char *concurrent_to_uuid, ip_address *ip, char *content_type, FILE *body, off_t payload_offset)
+warc_write_resource_record (char *resource_uuid, const char *url, const char *timestamp_str, const char *concurrent_to_uuid, ip_address *ip, const char *content_type, FILE *body, off_t payload_offset)
 {
   if (resource_uuid == NULL)
     {
diff --git a/src/warc.h b/src/warc.h
index 41829d1..ecfff60 100644
--- a/src/warc.h
+++ b/src/warc.h
@@ -13,7 +13,7 @@ FILE * warc_tempfile (void);
 
 bool warc_write_request_record (char *url, char *timestamp_str, char *concurrent_to_uuid, ip_address *ip, FILE *body, off_t payload_offset);
 bool warc_write_response_record (char *url, char *timestamp_str, char *concurrent_to_uuid, ip_address *ip, FILE *body, off_t payload_offset, char *mime_type, int response_code, char *redirect_location);
-bool warc_write_resource_record (char *resource_uuid, char *url, char *timestamp_str, char *concurrent_to_uuid, ip_address *ip, char *content_type, FILE *body, off_t payload_offset);
+bool warc_write_resource_record (char *resource_uuid, const char *url, const char *timestamp_str, const char *concurrent_to_uuid, ip_address *ip, const char *content_type, FILE *body, off_t payload_offset);
 
 #endif /* WARC_H */
 
-- 
1.7.10

Reply via email to