From 2e86829809c4a89eec3f13f8ad86a26c6c9c55de Mon Sep 17 00:00:00 2001 From: Tim Ruehsen Date: Mon, 14 May 2012 17:32:55 +0200 Subject: [PATCH] removed 'const' warnings. * hash.h (hash_table_put): Make argument "value" const. * hash.c (hash_table_put): Make argument value const. Cast `value' to void. * http.c (request_set_header): Make argument `name' const. Cast `value' and `name' to void*. (request_remove_header): Make argument `name' const. * url.c (url_file_name): Make `index_filename' static. * warc.h (warc_write_cdx_record): Make `url', `timestamp', `mime_type', `payload_digest', `redirect_location', `warc_filename', response_uuid' arguments const. Make `checksum' const. * warc.c (warc_write_date_header): Make the `timestamp' argument const. Make `extension' const. (warc_write_cdx_record): Make `url', `timestamp', `mime_type', `payload_digest', `redirect_location', `warc_filename', response_uuid' arguments const. Make `checksum' const. --- src/ChangeLog | 20 ++++++++++++++++++-- src/hash.c | 6 +++--- src/hash.h | 2 +- src/http.c | 14 +++++++------- src/url.c | 2 +- src/warc.c | 12 ++++++------ src/warc.h | 2 +- 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 8c6f4c80..68df65bb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,7 +1,23 @@ 2012-05-14 Tim Ruehsen - * gnutls.c: wgnutls_read_timeout (wgnutls_read_timeout): removed - warnings, moved fcntl stuff outside loop. + * gnutls.c (wgnutls_read_timeout): removed warnings, moved fcntl stuff + outside loop. + + * hash.h (hash_table_put): Make argument "value" const. + * hash.c (hash_table_put): Make argument value const. Cast `value' to + void. + * http.c (request_set_header): Make argument `name' const. Cast `value' + and `name' to void*. + (request_remove_header): Make argument `name' const. + * url.c (url_file_name): Make `index_filename' static. + * warc.h (warc_write_cdx_record): Make `url', `timestamp', `mime_type', + `payload_digest', `redirect_location', `warc_filename', response_uuid' + arguments const. Make `checksum' const. + * warc.c (warc_write_date_header): Make the `timestamp' argument const. + Make `extension' const. + (warc_write_cdx_record): Make `url', `timestamp', `mime_type', + `payload_digest', `redirect_location', `warc_filename', response_uuid' + arguments const. Make `checksum' const. 2012-05-13 Tim Ruehsen diff --git a/src/hash.c b/src/hash.c index 6c40801f..129ead1a 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 1dadf093..85767609 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 cf901929..8d4edba5 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 ddde798c..e44dfcd2 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 fa0830dc..a2cf102a 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 41829d12..ecfff600 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 */ -- 2.39.2