From 951f4d62fb98f9315da0c4b53a0e9c94c3154aeb Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Sun, 9 May 2021 08:16:02 -0400 Subject: [PATCH] TT#111150 remove dead code The internal-iovec bencode semantics are not used any more. Remove the relevant code. Change-Id: I22555bf74d935f48a793df441205a7f34b1b2d7f --- daemon/bencode.c | 22 ++-------------------- include/bencode.h | 20 -------------------- 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/daemon/bencode.c b/daemon/bencode.c index 9e607d353..2d2dfeedc 100644 --- a/daemon/bencode.c +++ b/daemon/bencode.c @@ -235,20 +235,6 @@ bencode_item_t *bencode_string_len(bencode_buffer_t *buf, const char *s, size_t return __bencode_string_alloc(buf, s, len, len, 1, BENCODE_STRING); } -bencode_item_t *bencode_string_iovec(bencode_buffer_t *buf, const struct iovec *iov, unsigned int iov_cnt, - size_t str_len) -{ - int i; - - if (str_len < 0) { - str_len = 0; - for (i = 0; i < iov_cnt; i++) - str_len += iov[i].iov_len; - } - - return __bencode_string_alloc(buf, iov, str_len, iov_cnt, iov_cnt, BENCODE_IOVEC); -} - bencode_item_t *bencode_integer(bencode_buffer_t *buf, long long int i) { bencode_item_t *ret; int alen, rlen; @@ -327,9 +313,7 @@ static int __bencode_iovec_dump(struct iovec *out, bencode_item_t *item) { child = child->sibling; } - if (item->type == BENCODE_IOVEC) - out += __bencode_iovec_cpy(out, item->iov[1].iov_base, item->iov[1].iov_len); - else if (item->iov[1].iov_base) + if (item->iov[1].iov_base) out += __bencode_iovec_cpy(out, &item->iov[1], 1); assert((out - orig) == item->iov_cnt); @@ -350,9 +334,7 @@ static size_t __bencode_str_dump(char *out, bencode_item_t *item) { child = child->sibling; } - if (item->type == BENCODE_IOVEC) - out += __bencode_str_cpy(out, item->iov[1].iov_base, item->iov[1].iov_len); - else if (item->iov[1].iov_base) + if (item->iov[1].iov_base) out += __bencode_str_cpy(out, &item->iov[1], 1); assert((out - orig) == item->str_len); diff --git a/include/bencode.h b/include/bencode.h index 488b24890..8011a4d11 100644 --- a/include/bencode.h +++ b/include/bencode.h @@ -23,7 +23,6 @@ enum bencode_type { BENCODE_INTEGER, /* long long int */ BENCODE_LIST, /* flat list of other objects */ BENCODE_DICTIONARY, /* dictionary of key/values pairs. keys are always strings */ - BENCODE_IOVEC, /* special case of a string, built through bencode_string_iovec() */ BENCODE_END_MARKER, /* used internally only */ }; @@ -119,11 +118,6 @@ INLINE bencode_item_t *bencode_dictionary_add_str(bencode_item_t *dict, const ch INLINE bencode_item_t *bencode_dictionary_str_add_str(bencode_item_t *dict, const str *key, const str *val); INLINE bencode_item_t *bencode_dictionary_add_str_dup(bencode_item_t *dict, const char *key, const str *val); -/* Ditto, but adds a string created through an iovec array to the dictionary. See - * bencode_string_iovec(). */ -INLINE bencode_item_t *bencode_dictionary_add_iovec(bencode_item_t *dict, const char *key, - const struct iovec *iov, unsigned int iov_cnt, size_t str_len); - /* Convenience functions to add the respective (newly created) objects to a dictionary */ INLINE bencode_item_t *bencode_dictionary_add_integer(bencode_item_t *dict, const char *key, long long int val); INLINE bencode_item_t *bencode_dictionary_add_dictionary(bencode_item_t *dict, const char *key); @@ -174,14 +168,6 @@ bencode_item_t *bencode_string_len_dup(bencode_buffer_t *buf, const char *s, siz INLINE bencode_item_t *bencode_string_dup(bencode_buffer_t *buf, const char *s); INLINE bencode_item_t *bencode_str_dup(bencode_buffer_t *buf, const str *s); -/* Creates a new byte-string object from an iovec array. The created object has different internal - * semantics (not a BENCODE_STRING, but a BENCODE_IOVEC) and must not be treated like other string - * objects. The array pointer and contents must still be valid and accessible when the complete - * document is encoded. The full length of the string composed of the iovec array is given in the - * "str_len" parameter, which can be negative, in which case the array is iterated to calculate the - * length. */ -bencode_item_t *bencode_string_iovec(bencode_buffer_t *buf, const struct iovec *iov, unsigned int iov_cnt, size_t str_len); - /* Convenience function to compare a string object to a regular C string. Returns 2 if object * isn't a string object, otherwise returns according to strcmp(). */ INLINE int bencode_strcmp(bencode_item_t *a, const char *b); @@ -592,10 +578,4 @@ INLINE str *bencode_get_str(bencode_item_t *in, str *out) { return out; } -INLINE bencode_item_t *bencode_dictionary_add_iovec(bencode_item_t *dict, const char *key, - const struct iovec *iov, unsigned int iov_cnt, size_t str_len) -{ - return bencode_dictionary_add(dict, key, bencode_string_iovec(bencode_item_buffer(dict), iov, iov_cnt, str_len)); -} - #endif