mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Killed warnings: uri_cache always evaluate as true
in the debug mode by adding macros object_lock_without_assert, object_unlock_without_assert, object_nolock_without_assert. These macros are almost identical to object_lock, object_unlock, object_nolock. New macros do not use the always true assertion for uri_cache.
This commit is contained in:
parent
2970056976
commit
f0717304f0
@ -47,11 +47,20 @@ struct object_head {
|
|||||||
if_assert_failed (obj)->object.refcount = 0; \
|
if_assert_failed (obj)->object.refcount = 0; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define object_sanity_check_without_assert(obj) \
|
||||||
|
do { \
|
||||||
|
assertm((obj)->object.refcount >= 0, \
|
||||||
|
"Object %s[%p] refcount underflow.", \
|
||||||
|
(obj)->object.name, obj); \
|
||||||
|
if_assert_failed (obj)->object.refcount = 0; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define object_set_name(obj, objname) \
|
#define object_set_name(obj, objname) \
|
||||||
do { (obj)->object.name = (objname); } while (0)
|
do { (obj)->object.name = (objname); } while (0)
|
||||||
#define INIT_OBJECT(name) { 0, name }
|
#define INIT_OBJECT(name) { 0, name }
|
||||||
#else
|
#else
|
||||||
#define object_sanity_check(obj)
|
#define object_sanity_check(obj)
|
||||||
|
#define object_sanity_check_without_assert(obj)
|
||||||
#define object_set_name(obj, name)
|
#define object_set_name(obj, name)
|
||||||
#define INIT_OBJECT(name) { 0 }
|
#define INIT_OBJECT(name) { 0 }
|
||||||
#endif /* CONFIG_DEBUG */
|
#endif /* CONFIG_DEBUG */
|
||||||
@ -81,4 +90,26 @@ struct object_head {
|
|||||||
object_lock_debug(obj, "initialized"); \
|
object_lock_debug(obj, "initialized"); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
/* These macros are here because of gcc warnings in uri.c . --witekfl */
|
||||||
|
#define object_lock_without_assert(obj) \
|
||||||
|
do { \
|
||||||
|
object_sanity_check_without_assert(obj); \
|
||||||
|
(obj)->object.refcount++; \
|
||||||
|
object_lock_debug(obj, "incremented"); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define object_unlock_without_assert(obj) \
|
||||||
|
do { \
|
||||||
|
(obj)->object.refcount--; \
|
||||||
|
object_lock_debug(obj, "decremented"); \
|
||||||
|
object_sanity_check_without_assert(obj); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define object_nolock_without_assert(obj, name) \
|
||||||
|
do { \
|
||||||
|
object_set_name(obj, name); \
|
||||||
|
object_sanity_check_without_assert(obj); \
|
||||||
|
object_lock_debug(obj, "initialized"); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1532,7 +1532,7 @@ get_uri_cache_entry(unsigned char *string, int length)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
object_lock(&uri_cache);
|
object_lock_without_assert(&uri_cache); /* was warning */
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
@ -1556,7 +1556,7 @@ get_uri(unsigned char *string, enum uri_component components)
|
|||||||
if (!is_object_used(&uri_cache)) {
|
if (!is_object_used(&uri_cache)) {
|
||||||
uri_cache.map = init_hash8();
|
uri_cache.map = init_hash8();
|
||||||
if (!uri_cache.map) return NULL;
|
if (!uri_cache.map) return NULL;
|
||||||
object_nolock(&uri_cache, "uri_cache");
|
object_nolock_without_assert(&uri_cache, "uri_cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = get_uri_cache_entry(string, strlen(string));
|
entry = get_uri_cache_entry(string, strlen(string));
|
||||||
@ -1594,7 +1594,7 @@ done_uri(struct uri *uri)
|
|||||||
mem_free(entry);
|
mem_free(entry);
|
||||||
|
|
||||||
/* Last URI frees the cache */
|
/* Last URI frees the cache */
|
||||||
object_unlock(&uri_cache);
|
object_unlock_without_assert(&uri_cache);
|
||||||
if (!is_object_used(&uri_cache))
|
if (!is_object_used(&uri_cache))
|
||||||
free_hash(&uri_cache.map);
|
free_hash(&uri_cache.map);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user