summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-17 15:08:27 +0200
committerStefan Schmidt <s.schmidt@samsung.com>2020-04-17 17:14:53 +0200
commit38d74c8a1a88cf4563894ec06404ce0bfe717669 (patch)
tree7cd30911718f95507d8eb7c3ead401009730c1f4
parent838a67d311fcbdfbc8f68f7be29c6864751a606a (diff)
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.c43
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
587 return strdup("Shot"); 587 return strdup("Shot");
588} 588}
589 589
590#define SAFE_PRINT(field, format, fallback) \
591 eina_strbuf_append_printf(buf, LDIFF(format)"/"RDIFF(format), \
592 e_obj1 ? e_obj1->field : fallback, \
593 e_obj2 ? e_obj2->field : fallback); \
594
595
590static char * 596static char *
591_obj_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED) 597_obj_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED)
592{ 598{
@@ -598,44 +604,21 @@ _obj_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED)
598 _Compare_Item_Data *vv = data; 604 _Compare_Item_Data *vv = data;
599 Exactness_Object *e_obj1 = vv->p1; 605 Exactness_Object *e_obj1 = vv->p1;
600 Exactness_Object *e_obj2 = vv->p2; 606 Exactness_Object *e_obj2 = vv->p2;
601 if ((!e_obj1 ^ !e_obj2) || strcmp(e_obj1->kl_name, e_obj2->kl_name)) 607 eina_strbuf_append(buf, "(");
602 eina_strbuf_append_printf(buf, "("LDIFF(%s)"/"RDIFF(%s)")", 608 SAFE_PRINT(kl_name, %s, "(NULL)")
603 e_obj1 ? e_obj1->kl_name : "XXXXX", 609 eina_strbuf_append(buf, ")");
604 e_obj2 ? e_obj2->kl_name : "XXXXX");
605 else
606 eina_strbuf_append_printf(buf, "%s", e_obj1->kl_name);
607 610
608 eina_strbuf_append(buf, " x = "); 611 eina_strbuf_append(buf, " x = ");
609 if ((!e_obj1 ^ !e_obj2) || e_obj1->x != e_obj2->x) 612 SAFE_PRINT(x, %d, -1)
610 eina_strbuf_append_printf(buf, LDIFF(%d)"/"RDIFF(%d),
611 e_obj1 ? e_obj1->x : -1,
612 e_obj2 ? e_obj2->x : -1);
613 else
614 eina_strbuf_append_printf(buf, "%d", e_obj1->x);
615 613
616 eina_strbuf_append(buf, " y = "); 614 eina_strbuf_append(buf, " y = ");
617 if ((!e_obj1 ^ !e_obj2) || e_obj1->y != e_obj2->y) 615 SAFE_PRINT(y, %d, -1)
618 eina_strbuf_append_printf(buf, LDIFF(%d)"/"RDIFF(%d),
619 e_obj1 ? e_obj1->y : -1,
620 e_obj2 ? e_obj2->y : -1);
621 else
622 eina_strbuf_append_printf(buf, "%d", e_obj1->y);
623 616
624 eina_strbuf_append(buf, " w = "); 617 eina_strbuf_append(buf, " w = ");
625 if ((!e_obj1 ^ !e_obj2) || e_obj1->w != e_obj2->w) 618 SAFE_PRINT(w, %d, -1)
626 eina_strbuf_append_printf(buf, LDIFF(%d)"/"RDIFF(%d),
627 e_obj1 ? e_obj1->w : -1,
628 e_obj2 ? e_obj2->w : -1);
629 else
630 eina_strbuf_append_printf(buf, "%d", e_obj1->w);
631 619
632 eina_strbuf_append(buf, " h = "); 620 eina_strbuf_append(buf, " h = ");
633 if ((!e_obj1 ^ !e_obj2) || e_obj1->h != e_obj2->h) 621 SAFE_PRINT(h, %d, -1)
634 eina_strbuf_append_printf(buf, LDIFF(%d)"/"RDIFF(%d),
635 e_obj1 ? e_obj1->h : -1,
636 e_obj2 ? e_obj2->h : -1);
637 else
638 eina_strbuf_append_printf(buf, "%d", e_obj1->h);
639 622
640 if (e_obj1 && e_obj2 && _are_objs_different(e_obj1, e_obj2, EINA_FALSE)) 623 if (e_obj1 && e_obj2 && _are_objs_different(e_obj1, e_obj2, EINA_FALSE))
641 eina_strbuf_append(buf, " - DIFF INSIDE"); 624 eina_strbuf_append(buf, " - DIFF INSIDE");