Fix a few more "unreachable code" warnings
This commit is contained in:
parent
2304856340
commit
11e3ec444a
|
@ -42,7 +42,7 @@ HB_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
#ifndef HB_DEBUG_BLOB
|
#ifndef HB_DEBUG_BLOB
|
||||||
#define HB_DEBUG_BLOB HB_DEBUG+0
|
#define HB_DEBUG_BLOB (HB_DEBUG+0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hb_blob_t _hb_blob_nil = {
|
hb_blob_t _hb_blob_nil = {
|
||||||
|
|
|
@ -60,7 +60,7 @@ typedef struct {
|
||||||
/* Debug */
|
/* Debug */
|
||||||
|
|
||||||
#ifndef HB_DEBUG_OBJECT
|
#ifndef HB_DEBUG_OBJECT
|
||||||
#define HB_DEBUG_OBJECT HB_DEBUG+0
|
#define HB_DEBUG_OBJECT (HB_DEBUG+0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -68,11 +68,11 @@ _hb_trace_object (const void *obj,
|
||||||
hb_reference_count_t *ref_count,
|
hb_reference_count_t *ref_count,
|
||||||
const char *function)
|
const char *function)
|
||||||
{
|
{
|
||||||
if (HB_DEBUG_OBJECT)
|
(void) (HB_DEBUG_OBJECT &&
|
||||||
fprintf (stderr, "OBJECT(%p) refcount=%d %s\n",
|
fprintf (stderr, "OBJECT(%p) refcount=%d %s\n",
|
||||||
obj,
|
obj,
|
||||||
HB_REFERENCE_COUNT_GET_VALUE (*ref_count),
|
HB_REFERENCE_COUNT_GET_VALUE (*ref_count),
|
||||||
function);
|
function));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TRACE_OBJECT(obj) _hb_trace_object (obj, &obj->ref_count, __FUNCTION__)
|
#define TRACE_OBJECT(obj) _hb_trace_object (obj, &obj->ref_count, __FUNCTION__)
|
||||||
|
|
|
@ -152,8 +152,8 @@ ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type))
|
||||||
template <int max_depth>
|
template <int max_depth>
|
||||||
struct hb_trace_t {
|
struct hb_trace_t {
|
||||||
explicit hb_trace_t (unsigned int *pdepth, const char *what, const char *function, const void *obj) : pdepth(pdepth) {
|
explicit hb_trace_t (unsigned int *pdepth, const char *what, const char *function, const void *obj) : pdepth(pdepth) {
|
||||||
if (*pdepth < max_depth)
|
(void) (*pdepth < max_depth &&
|
||||||
fprintf (stderr, "%s(%p) %-*d-> %s\n", what, obj, *pdepth, *pdepth, function);
|
fprintf (stderr, "%s(%p) %-*d-> %s\n", what, obj, *pdepth, *pdepth, function));
|
||||||
if (max_depth) ++*pdepth;
|
if (max_depth) ++*pdepth;
|
||||||
}
|
}
|
||||||
~hb_trace_t (void) { if (max_depth) --*pdepth; }
|
~hb_trace_t (void) { if (max_depth) --*pdepth; }
|
||||||
|
@ -173,7 +173,7 @@ struct hb_trace_t<0> {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HB_DEBUG_SANITIZE
|
#ifndef HB_DEBUG_SANITIZE
|
||||||
#define HB_DEBUG_SANITIZE HB_DEBUG+0
|
#define HB_DEBUG_SANITIZE (HB_DEBUG+0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,17 +192,17 @@ struct hb_sanitize_context_t
|
||||||
this->edit_count = 0;
|
this->edit_count = 0;
|
||||||
this->debug_depth = 0;
|
this->debug_depth = 0;
|
||||||
|
|
||||||
if (HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "sanitize %p init [%p..%p] (%lu bytes)\n",
|
fprintf (stderr, "sanitize %p init [%p..%p] (%lu bytes)\n",
|
||||||
this->blob, this->start, this->end,
|
this->blob, this->start, this->end,
|
||||||
(unsigned long) (this->end - this->start));
|
(unsigned long) (this->end - this->start)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void finish (void)
|
inline void finish (void)
|
||||||
{
|
{
|
||||||
if (HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "sanitize %p fini [%p..%p] %u edit requests\n",
|
fprintf (stderr, "sanitize %p fini [%p..%p] %u edit requests\n",
|
||||||
this->blob, this->start, this->end, this->edit_count);
|
this->blob, this->start, this->end, this->edit_count));
|
||||||
|
|
||||||
hb_blob_unlock (this->blob);
|
hb_blob_unlock (this->blob);
|
||||||
hb_blob_destroy (this->blob);
|
hb_blob_destroy (this->blob);
|
||||||
|
@ -217,13 +217,13 @@ struct hb_sanitize_context_t
|
||||||
p <= this->end &&
|
p <= this->end &&
|
||||||
(unsigned int) (this->end - p) >= len;
|
(unsigned int) (this->end - p) >= len;
|
||||||
|
|
||||||
if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE) \
|
(void) (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
|
fprintf (stderr, "SANITIZE(%p) %-*d-> range [%p..%p] (%d bytes) in [%p..%p] -> %s\n",
|
||||||
p,
|
p,
|
||||||
this->debug_depth, this->debug_depth,
|
this->debug_depth, this->debug_depth,
|
||||||
p, p + len, len,
|
p, p + len, len,
|
||||||
this->start, this->end,
|
this->start, this->end,
|
||||||
ret ? "pass" : "FAIL");
|
ret ? "pass" : "FAIL"));
|
||||||
|
|
||||||
return likely (ret);
|
return likely (ret);
|
||||||
}
|
}
|
||||||
|
@ -233,13 +233,13 @@ struct hb_sanitize_context_t
|
||||||
const char *p = (const char *) base;
|
const char *p = (const char *) base;
|
||||||
bool overflows = record_size > 0 && len >= ((unsigned int) -1) / record_size;
|
bool overflows = record_size > 0 && len >= ((unsigned int) -1) / record_size;
|
||||||
|
|
||||||
if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \
|
fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n",
|
||||||
p,
|
p,
|
||||||
this->debug_depth, this->debug_depth,
|
this->debug_depth, this->debug_depth,
|
||||||
p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
|
p, p + (record_size * len), record_size, len, (unsigned long) record_size * len,
|
||||||
this->start, this->end,
|
this->start, this->end,
|
||||||
!overflows ? "does not overflow" : "OVERFLOWS FAIL");
|
!overflows ? "does not overflow" : "OVERFLOWS FAIL"));
|
||||||
|
|
||||||
return likely (!overflows && this->check_range (base, record_size * len));
|
return likely (!overflows && this->check_range (base, record_size * len));
|
||||||
}
|
}
|
||||||
|
@ -255,14 +255,14 @@ struct hb_sanitize_context_t
|
||||||
const char *p = (const char *) base;
|
const char *p = (const char *) base;
|
||||||
this->edit_count++;
|
this->edit_count++;
|
||||||
|
|
||||||
if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n", \
|
fprintf (stderr, "SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s\n",
|
||||||
p,
|
p,
|
||||||
this->debug_depth, this->debug_depth,
|
this->debug_depth, this->debug_depth,
|
||||||
this->edit_count,
|
this->edit_count,
|
||||||
p, p + len, len,
|
p, p + len, len,
|
||||||
this->start, this->end,
|
this->start, this->end,
|
||||||
this->writable ? "granted" : "REJECTED");
|
this->writable ? "granted" : "REJECTED"));
|
||||||
|
|
||||||
return this->writable;
|
return this->writable;
|
||||||
}
|
}
|
||||||
|
@ -290,8 +290,8 @@ struct Sanitizer
|
||||||
return hb_blob_create_empty ();
|
return hb_blob_create_empty ();
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
if (HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "Sanitizer %p start %s\n", blob, HB_FUNC);
|
fprintf (stderr, "Sanitizer %p start %s\n", blob, HB_FUNC));
|
||||||
|
|
||||||
c->init (blob);
|
c->init (blob);
|
||||||
|
|
||||||
|
@ -305,17 +305,17 @@ struct Sanitizer
|
||||||
sane = t->sanitize (c);
|
sane = t->sanitize (c);
|
||||||
if (sane) {
|
if (sane) {
|
||||||
if (c->edit_count) {
|
if (c->edit_count) {
|
||||||
if (HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "Sanitizer %p passed first round with %d edits; doing a second round %s\n",
|
fprintf (stderr, "Sanitizer %p passed first round with %d edits; doing a second round %s\n",
|
||||||
blob, c->edit_count, HB_FUNC);
|
blob, c->edit_count, HB_FUNC));
|
||||||
|
|
||||||
/* sanitize again to ensure no toe-stepping */
|
/* sanitize again to ensure no toe-stepping */
|
||||||
c->edit_count = 0;
|
c->edit_count = 0;
|
||||||
sane = t->sanitize (c);
|
sane = t->sanitize (c);
|
||||||
if (c->edit_count) {
|
if (c->edit_count) {
|
||||||
if (HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "Sanitizer %p requested %d edits in second round; FAILLING %s\n",
|
fprintf (stderr, "Sanitizer %p requested %d edits in second round; FAILLING %s\n",
|
||||||
blob, c->edit_count, HB_FUNC);
|
blob, c->edit_count, HB_FUNC));
|
||||||
sane = false;
|
sane = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,14 +325,14 @@ struct Sanitizer
|
||||||
c->finish ();
|
c->finish ();
|
||||||
if (edit_count && !hb_blob_is_writable (blob) && hb_blob_try_writable (blob)) {
|
if (edit_count && !hb_blob_is_writable (blob) && hb_blob_try_writable (blob)) {
|
||||||
/* ok, we made it writable by relocating. try again */
|
/* ok, we made it writable by relocating. try again */
|
||||||
if (HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "Sanitizer %p retry %s\n", blob, HB_FUNC);
|
fprintf (stderr, "Sanitizer %p retry %s\n", blob, HB_FUNC));
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HB_DEBUG_SANITIZE)
|
(void) (HB_DEBUG_SANITIZE &&
|
||||||
fprintf (stderr, "Sanitizer %p %s %s\n", blob, sane ? "passed" : "FAILED", HB_FUNC);
|
fprintf (stderr, "Sanitizer %p %s %s\n", blob, sane ? "passed" : "FAILED", HB_FUNC));
|
||||||
if (sane)
|
if (sane)
|
||||||
return blob;
|
return blob;
|
||||||
else {
|
else {
|
||||||
|
@ -577,18 +577,16 @@ struct GenericArrayOf
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (unlikely (!sanitize_shallow (c))) return false;
|
if (unlikely (!sanitize_shallow (c))) return false;
|
||||||
|
|
||||||
/* Note: for structs that do not reference other structs,
|
/* Note: for structs that do not reference other structs,
|
||||||
* we do not need to call their sanitize() as we already did
|
* we do not need to call their sanitize() as we already did
|
||||||
* a bound check on the aggregate array size, hence the return.
|
* a bound check on the aggregate array size. We just include
|
||||||
|
* a small unreachable expression to make sure the structs
|
||||||
|
* pointed to do have a simple sanitize(), ie. they do not
|
||||||
|
* reference other structs via offsets.
|
||||||
*/
|
*/
|
||||||
return true;
|
(void) (false && array[0].sanitize (c));
|
||||||
/* We do keep this code though to make sure the structs pointed
|
|
||||||
* to do have a simple sanitize(), ie. they do not reference
|
|
||||||
* other structs. */
|
|
||||||
unsigned int count = len;
|
|
||||||
for (unsigned int i = 0; i < count; i++)
|
|
||||||
if (unlikely (!array[i].sanitize (c)))
|
|
||||||
return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
|
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
|
||||||
|
@ -688,18 +686,16 @@ struct HeadlessArrayOf
|
||||||
inline bool sanitize (hb_sanitize_context_t *c) {
|
inline bool sanitize (hb_sanitize_context_t *c) {
|
||||||
TRACE_SANITIZE ();
|
TRACE_SANITIZE ();
|
||||||
if (unlikely (!sanitize_shallow (c))) return false;
|
if (unlikely (!sanitize_shallow (c))) return false;
|
||||||
|
|
||||||
/* Note: for structs that do not reference other structs,
|
/* Note: for structs that do not reference other structs,
|
||||||
* we do not need to call their sanitize() as we already did
|
* we do not need to call their sanitize() as we already did
|
||||||
* a bound check on the aggregate array size, hence the return.
|
* a bound check on the aggregate array size. We just include
|
||||||
|
* a small unreachable expression to make sure the structs
|
||||||
|
* pointed to do have a simple sanitize(), ie. they do not
|
||||||
|
* reference other structs via offsets.
|
||||||
*/
|
*/
|
||||||
return true;
|
(void) (false && array[0].sanitize (c));
|
||||||
/* We do keep this code though to make sure the structs pointed
|
|
||||||
* to do have a simple sanitize(), ie. they do not reference
|
|
||||||
* other structs. */
|
|
||||||
unsigned int count = len ? len - 1 : 0;
|
|
||||||
for (unsigned int i = 0; i < count; i++)
|
|
||||||
if (unlikely (!array[i].sanitize (c)))
|
|
||||||
return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ HB_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
||||||
#ifndef HB_DEBUG_APPLY
|
#ifndef HB_DEBUG_APPLY
|
||||||
#define HB_DEBUG_APPLY HB_DEBUG+0
|
#define HB_DEBUG_APPLY (HB_DEBUG+0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TRACE_APPLY() \
|
#define TRACE_APPLY() \
|
||||||
|
|
|
@ -257,8 +257,7 @@ _hb_trace (const char *what,
|
||||||
unsigned int depth,
|
unsigned int depth,
|
||||||
unsigned int max_depth)
|
unsigned int max_depth)
|
||||||
{
|
{
|
||||||
if (depth < max_depth)
|
(void) ((depth < max_depth) && fprintf (stderr, "%s(%p) %-*d-> %s\n", what, obj, depth, depth, function));
|
||||||
fprintf (stderr, "%s(%p) %-*d-> %s\n", what, obj, depth, depth, function);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue