diff options
author | Marcel Hollerbach <mail@marcel-hollerbach.de> | 2020-04-17 15:08:27 +0200 |
---|---|---|
committer | Stefan Schmidt <s.schmidt@samsung.com> | 2020-04-17 17:14:53 +0200 |
commit | 38d74c8a1a88cf4563894ec06404ce0bfe717669 (patch) | |
tree | 7cd30911718f95507d8eb7c3ead401009730c1f4 | |
parent | 838a67d311fcbdfbc8f68f7be29c6864751a606a (diff) | |
download | efl-38d74c8a1a88cf4563894ec06404ce0bfe717669.tar.gz |
exactness-inspect: sanitize if clause
these if clause where a bit bottom up, and the xor operation here seemed
totally wrong, with this code we are simply displaying both entiteis of
the two structs when they are there. *or* we are replacing it with the
fallback.
CID1419875
Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org>
Differential Revision: https://phab.enlightenment.org/D11719
-rw-r--r-- | src/bin/exactness/inspect.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/src/bin/exactness/inspect.c b/src/bin/exactness/inspect.c index 1e1dc48018..926f9810f5 100644 --- a/src/bin/exactness/inspect.c +++ b/src/bin/exactness/inspect.c @@ -587,6 +587,12 @@ _objs_text_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char return strdup("Shot"); } +#define SAFE_PRINT(field, format, fallback) \ + eina_strbuf_append_printf(buf, LDIFF(format)"/"RDIFF(format), \ + e_obj1 ? e_obj1->field : fallback, \ + e_obj2 ? e_obj2->field : fallback); \ + + static char * _obj_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED) { @@ -598,44 +604,21 @@ _obj_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED) _Compare_Item_Data *vv = data; Exactness_Object *e_obj1 = vv->p1; Exactness_Object *e_obj2 = vv->p2; - if ((!e_obj1 ^ !e_obj2) || strcmp(e_obj1->kl_name, e_obj2->kl_name)) - eina_strbuf_append_printf(buf, "("LDIFF(%s)"/"RDIFF(%s)")", - e_obj1 ? e_obj1->kl_name : "XXXXX", - e_obj2 ? e_obj2->kl_name : "XXXXX"); - else - eina_strbuf_append_printf(buf, "%s", e_obj1->kl_name); + eina_strbuf_append(buf, "("); + SAFE_PRINT(kl_name, %s, "(NULL)") + eina_strbuf_append(buf, ")"); eina_strbuf_append(buf, " x = "); - if ((!e_obj1 ^ !e_obj2) || e_obj1->x != e_obj2->x) - eina_strbuf_append_printf(buf, LDIFF(%d)"/"RDIFF(%d), - e_obj1 ? e_obj1->x : -1, - e_obj2 ? e_obj2->x : -1); - else - eina_strbuf_append_printf(buf, "%d", e_obj1->x); + SAFE_PRINT(x, %d, -1) eina_strbuf_append(buf, " y = "); - if ((!e_obj1 ^ !e_obj2) || e_obj1->y != e_obj2->y) - eina_strbuf_append_printf(buf, LDIFF(%d)"/"RDIFF(%d), - e_obj1 ? e_obj1->y : -1, - e_obj2 ? e_obj2->y : -1); - else - eina_strbuf_append_printf(buf, "%d", e_obj1->y); + SAFE_PRINT(y, %d, -1) eina_strbuf_append(buf, " w = "); - if ((!e_obj1 ^ !e_obj2) || e_obj1->w != e_obj2->w) - eina_strbuf_append_printf(buf, LDIFF(%d)"/"RDIFF(%d), - e_obj1 ? e_obj1->w : -1, - e_obj2 ? e_obj2->w : -1); - else - eina_strbuf_append_printf(buf, "%d", e_obj1->w); + SAFE_PRINT(w, %d, -1) eina_strbuf_append(buf, " h = "); - if ((!e_obj1 ^ !e_obj2) || e_obj1->h != e_obj2->h) - eina_strbuf_append_printf(buf, LDIFF(%d)"/"RDIFF(%d), - e_obj1 ? e_obj1->h : -1, - e_obj2 ? e_obj2->h : -1); - else - eina_strbuf_append_printf(buf, "%d", e_obj1->h); + SAFE_PRINT(h, %d, -1) if (e_obj1 && e_obj2 && _are_objs_different(e_obj1, e_obj2, EINA_FALSE)) eina_strbuf_append(buf, " - DIFF INSIDE"); |