summaryrefslogtreecommitdiffstats
path: root/src/bencoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bencoding.c')
-rw-r--r--src/bencoding.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/bencoding.c b/src/bencoding.c
index 11acee9..8a044e2 100644
--- a/src/bencoding.c
+++ b/src/bencoding.c
@@ -579,7 +579,7 @@ struct bencoding * bdecode (const char * s, int len, enum benc opts) {
* @param key [in] the path
*/
-struct bencoding * bpath (struct bencoding * benc, const char * key) {
+struct bencoding * bpath (const struct bencoding * benc, const char * key) {
if (!benc)
return NULL;
if (!benc->child)
@@ -596,17 +596,23 @@ struct bencoding * bpath (struct bencoding * benc, const char * key) {
char buf[512];
sprintf(buf, "%ld", benc->key->intvalue);
if (len == strlen(buf) && !strncmp(buf, key, len)) {
- if (!c)
+ if (!c) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
return benc;
- else
+#pragma GCC diagnostic pop
+ } else
return bpath(benc, key+len);
}
}
if (benc->key && benc->key->type & string) {
if (len == benc->key->valuelen && !strncmp(key, benc->key->value, len)) {
- if (!c)
+ if (!c) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
return benc;
- else
+#pragma GCC diagnostic pop
+ } else
return bpath(benc, key+len);
}
}
@@ -618,11 +624,11 @@ struct bencoding * bpath (struct bencoding * benc, const char * key) {
/**
* macro that loops following code body across a list or values of dict
*
- * @param elem [out] name of element that will be used for value while looping
* @param list [in] list/dict of values
+ * @param elem [out] name of element that will be used for value while looping
*/
-#define bforeach(elem, list) \
+#define bforeach(list, elem) \
for (struct bencoding * elem = list ? list->child : NULL; elem; elem = elem->next)
/**