summaryrefslogtreecommitdiff
path: root/src/lib/eet
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-06-15 16:34:32 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-06-15 16:34:32 -0400
commit4631d4ce7e7dca31310c00ea51f30fd186991714 (patch)
treeffd9ce28420217c362d937cc59697ebc3e5356c2 /src/lib/eet
parentc74d964afac1eda6e6473b751f98f283f9fe0c38 (diff)
eet: print errors any time an error occurs while decoding
Summary: catching these errors was super annoying since the codebase is mostly comprised of goto statements, so this should make future debugging easier Depends on D6292 Reviewers: devilhorns, ManMower Reviewed By: ManMower Subscribers: cedric, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D6293
Diffstat (limited to 'src/lib/eet')
-rw-r--r--src/lib/eet/eet_data.c89
1 files changed, 44 insertions, 45 deletions
diff --git a/src/lib/eet/eet_data.c b/src/lib/eet/eet_data.c
index f34e89e47f..cf80e42e74 100644
--- a/src/lib/eet/eet_data.c
+++ b/src/lib/eet/eet_data.c
@@ -626,7 +626,7 @@ static int _eet_data_words_bigendian = -1;
626 Size, \ 626 Size, \
627 SubSize > 0 ? Data_Ret : NULL, \ 627 SubSize > 0 ? Data_Ret : NULL, \
628 SubSize); \ 628 SubSize); \
629 if (!Data_Ret) { goto Label; } \ 629 EINA_SAFETY_ON_NULL_GOTO(Data_Ret, Label); \
630 } while (0) 630 } while (0)
631 631
632#define EET_I_STRING 1 << 4 632#define EET_I_STRING 1 << 4
@@ -1727,8 +1727,7 @@ case EET_T_ ## Type: type += EET_I_ ## Type; break;
1727 size = eet_data_put_int(ed, &s, &size_ret); 1727 size = eet_data_put_int(ed, &s, &size_ret);
1728 1728
1729 /* FIXME: If something goes wrong the resulting file will be corrupted. */ 1729 /* FIXME: If something goes wrong the resulting file will be corrupted. */
1730 if (!size) 1730 EINA_SAFETY_ON_TRUE_GOTO(!size, on_error);
1731 goto on_error;
1732 1731
1733 eet_data_stream_write(ds, buf, 4); 1732 eet_data_stream_write(ds, buf, 4);
1734 1733
@@ -3610,12 +3609,12 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
3610 3609
3611 memset(&chnk, 0, sizeof(Eet_Data_Chunk)); 3610 memset(&chnk, 0, sizeof(Eet_Data_Chunk));
3612 eet_data_chunk_get(ed, &chnk, data_in, size_in); 3611 eet_data_chunk_get(ed, &chnk, data_in, size_in);
3613 if (!chnk.name) 3612 EINA_SAFETY_ON_NULL_GOTO(chnk.name, error);
3614 goto error;
3615 3613
3616 if (edd) 3614 if (edd)
3617 if (strcmp(chnk.name, edd->name)) 3615 {
3618 goto error; 3616 EINA_SAFETY_ON_TRUE_GOTO(strcmp(chnk.name, edd->name), error);
3617 }
3619 3618
3620 p = chnk.data; 3619 p = chnk.data;
3621 if (ed) 3620 if (ed)
@@ -3659,6 +3658,7 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
3659 case EET_G_UNION: 3658 case EET_G_UNION:
3660 case EET_G_VARIANT: 3659 case EET_G_VARIANT:
3661 default: 3660 default:
3661 ERR("Decoding error!");
3662 goto error; 3662 goto error;
3663 } 3663 }
3664 } 3664 }
@@ -3674,8 +3674,7 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
3674 /* get next data chunk */ 3674 /* get next data chunk */
3675 memset(&echnk, 0, sizeof(Eet_Data_Chunk)); 3675 memset(&echnk, 0, sizeof(Eet_Data_Chunk));
3676 eet_data_chunk_get(ed, &echnk, p, size); 3676 eet_data_chunk_get(ed, &echnk, p, size);
3677 if (!echnk.name) 3677 EINA_SAFETY_ON_NULL_GOTO(echnk.name, error); /* FIXME: don't REPLY on edd - work without */
3678 goto error; /* FIXME: don't REPLY on edd - work without */
3679 3678
3680 if (edd) 3679 if (edd)
3681 { 3680 {
@@ -3723,8 +3722,7 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
3723 echnk.data, 3722 echnk.data,
3724 ((char *)echnk.data) + echnk.size, 3723 ((char *)echnk.data) + echnk.size,
3725 dd); 3724 dd);
3726 if (ret <= 0) 3725 EINA_SAFETY_ON_TRUE_GOTO(ret <= 0, error);
3727 goto error;
3728 3726
3729 child = eet_data_node_simple_type(type, echnk.name, dd); 3727 child = eet_data_node_simple_type(type, echnk.name, dd);
3730 3728
@@ -3744,8 +3742,7 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
3744 &p, 3742 &p,
3745 &size); 3743 &size);
3746 3744
3747 if (ret <= 0) 3745 EINA_SAFETY_ON_TRUE_GOTO(ret <= 0, error);
3748 goto error;
3749 } 3746 }
3750 3747
3751 /* advance to next chunk */ 3748 /* advance to next chunk */
@@ -3888,11 +3885,9 @@ eet_data_get_hash(Eet_Free_Context *context,
3888 echnk->data, 3885 echnk->data,
3889 ((char *)echnk->data) + echnk->size, 3886 ((char *)echnk->data) + echnk->size,
3890 &key); 3887 &key);
3891 if (ret <= 0) 3888 EINA_SAFETY_ON_TRUE_GOTO(ret <= 0, on_error);
3892 goto on_error;
3893 3889
3894 if (!key) 3890 EINA_SAFETY_ON_NULL_GOTO(key, on_error);
3895 goto on_error;
3896 3891
3897 /* Advance to next chunk */ 3892 /* Advance to next chunk */
3898 NEXT_CHUNK((*p), (*size), (*echnk), ed); 3893 NEXT_CHUNK((*p), (*size), (*echnk), ed);
@@ -3900,13 +3895,15 @@ eet_data_get_hash(Eet_Free_Context *context,
3900 3895
3901 /* Read value */ 3896 /* Read value */
3902 eet_data_chunk_get(ed, echnk, *p, *size); 3897 eet_data_chunk_get(ed, echnk, *p, *size);
3903 if (!echnk->name) 3898 EINA_SAFETY_ON_NULL_GOTO(echnk->name, on_error);
3904 goto on_error;
3905 3899
3906 if (ede) 3900 if (ede)
3907 if ((ede->group_type != echnk->group_type) 3901 if ((ede->group_type != echnk->group_type)
3908 || (ede->type != echnk->type)) 3902 || (ede->type != echnk->type))
3909 goto on_error; 3903 {
3904 ERR("ERROR!");
3905 goto on_error;
3906 }
3910 3907
3911 if (IS_POINTER_TYPE(echnk->type)) 3908 if (IS_POINTER_TYPE(echnk->type))
3912 POINTER_TYPE_DECODE(context, 3909 POINTER_TYPE_DECODE(context,
@@ -4027,17 +4024,26 @@ eet_data_get_array(Eet_Free_Context *context,
4027 4024
4028 eet_data_chunk_get(ed, echnk, *p, *size); 4025 eet_data_chunk_get(ed, echnk, *p, *size);
4029 if (!echnk->name || strcmp(echnk->name, name) != 0) 4026 if (!echnk->name || strcmp(echnk->name, name) != 0)
4030 goto on_error; /* get the data */ 4027 {
4028 ERR("ERROR!");
4029 goto on_error;
4030 }
4031 4031
4032 if ((echnk->group_type != group_type) 4032 if ((echnk->group_type != group_type)
4033 || ((echnk->type != type) && (echnk->type != EET_T_NULL))) 4033 || ((echnk->type != type) && (echnk->type != EET_T_NULL)))
4034 goto on_error; 4034 {
4035 ERR("ERROR!");
4036 goto on_error;
4037 }
4035 4038
4036 if (ede) 4039 if (ede)
4037 if ((ede->group_type != echnk->group_type) 4040 if ((ede->group_type != echnk->group_type)
4038 || ((echnk->type != ede->type) && (echnk->type != EET_T_NULL))) 4041 || ((echnk->type != ede->type) && (echnk->type != EET_T_NULL)))
4039 goto on_error; 4042 {
4040 4043 ERR("ERROR!");
4044 goto on_error;
4045 }
4046 /* get the data */
4041 /* get the destination pointer */ 4047 /* get the destination pointer */
4042 if (ede) 4048 if (ede)
4043 { 4049 {
@@ -4093,8 +4099,7 @@ eet_data_get_array(Eet_Free_Context *context,
4093 else 4099 else
4094 array = eet_node_var_array_new(name, childs); 4100 array = eet_node_var_array_new(name, childs);
4095 4101
4096 if (!array) 4102 EINA_SAFETY_ON_NULL_GOTO(array, on_error);
4097 goto on_error;
4098 4103
4099 eet_node_struct_append(parent, name, array); 4104 eet_node_struct_append(parent, name, array);
4100 } 4105 }
@@ -4193,8 +4198,7 @@ eet_data_get_union(Eet_Free_Context *context,
4193 echnk->data, 4198 echnk->data,
4194 ((char *)echnk->data) + echnk->size, 4199 ((char *)echnk->data) + echnk->size,
4195 &union_type); 4200 &union_type);
4196 if (ret <= 0) 4201 EINA_SAFETY_ON_TRUE_GOTO(ret <= 0, on_error);
4197 goto on_error;
4198 4202
4199 /* Advance to next chunk */ 4203 /* Advance to next chunk */
4200 NEXT_CHUNK((*p), (*size), (*echnk), ed); 4204 NEXT_CHUNK((*p), (*size), (*echnk), ed);
@@ -4202,13 +4206,12 @@ eet_data_get_union(Eet_Free_Context *context,
4202 4206
4203 /* Read value */ 4207 /* Read value */
4204 eet_data_chunk_get(ed, echnk, *p, *size); 4208 eet_data_chunk_get(ed, echnk, *p, *size);
4205 if (!echnk->name) 4209 EINA_SAFETY_ON_NULL_GOTO(echnk->name, on_error);
4206 goto on_error;
4207 4210
4208 if (ede) 4211 if (ede)
4209 { 4212 {
4210 EET_ASSERT(!(ede->group_type != group_type || ede->type != type), 4213 EET_ASSERT(!(ede->group_type != group_type || ede->type != type),
4211 goto on_error); 4214 ERR("ERROR!"); goto on_error);
4212 4215
4213 /* Search the structure of the union to decode */ 4216 /* Search the structure of the union to decode */
4214 for (i = 0; i < ede->subtype->elements.num; ++i) 4217 for (i = 0; i < ede->subtype->elements.num; ++i)
@@ -4233,7 +4236,7 @@ eet_data_get_union(Eet_Free_Context *context,
4233 } 4236 }
4234 else 4237 else
4235 { 4238 {
4236 EET_ASSERT(sede->subtype, goto on_error); 4239 EET_ASSERT(sede->subtype, ERR("ERROR!"); goto on_error);
4237 data_ret = _eet_data_descriptor_decode(context, 4240 data_ret = _eet_data_descriptor_decode(context,
4238 ed, 4241 ed,
4239 sede->subtype, 4242 sede->subtype,
@@ -4241,8 +4244,7 @@ eet_data_get_union(Eet_Free_Context *context,
4241 echnk->size, 4244 echnk->size,
4242 data, 4245 data,
4243 sede->subtype->size); 4246 sede->subtype->size);
4244 if (!data_ret) 4247 EINA_SAFETY_ON_NULL_GOTO(data_ret, on_error);
4245 goto on_error;
4246 } 4248 }
4247 4249
4248 /* Set union type. */ 4250 /* Set union type. */
@@ -4273,6 +4275,7 @@ eet_data_get_union(Eet_Free_Context *context,
4273 ed, NULL, 4275 ed, NULL,
4274 echnk->data, echnk->size, 4276 echnk->data, echnk->size,
4275 NULL, 0); 4277 NULL, 0);
4278 ERR("ERROR!");
4276 goto on_error; 4279 goto on_error;
4277 } 4280 }
4278 4281
@@ -4422,8 +4425,7 @@ eet_data_get_variant(Eet_Free_Context *context,
4422 echnk->data, 4425 echnk->data,
4423 ((char *)echnk->data) + echnk->size, 4426 ((char *)echnk->data) + echnk->size,
4424 &union_type); 4427 &union_type);
4425 if (ret <= 0) 4428 EINA_SAFETY_ON_TRUE_GOTO(ret <= 0, on_error);
4426 goto on_error;
4427 4429
4428 /* Advance to next chunk */ 4430 /* Advance to next chunk */
4429 NEXT_CHUNK((*p), (*size), (*echnk), ed); 4431 NEXT_CHUNK((*p), (*size), (*echnk), ed);
@@ -4431,14 +4433,13 @@ eet_data_get_variant(Eet_Free_Context *context,
4431 4433
4432 /* Read value */ 4434 /* Read value */
4433 eet_data_chunk_get(ed, echnk, *p, *size); 4435 eet_data_chunk_get(ed, echnk, *p, *size);
4434 if (!echnk->name) 4436 EINA_SAFETY_ON_NULL_GOTO(echnk->name, on_error);
4435 goto on_error;
4436 4437
4437 if (ede) 4438 if (ede)
4438 { 4439 {
4439 char *ut; 4440 char *ut;
4440 4441
4441 EET_ASSERT(ede->subtype, goto on_error); 4442 EET_ASSERT(ede->subtype, ERR("ERROR!"); goto on_error);
4442 4443
4443 if ((!ed) || (!ede->subtype->func.str_direct_alloc)) 4444 if ((!ed) || (!ede->subtype->func.str_direct_alloc))
4444 { 4445 {
@@ -4476,15 +4477,13 @@ eet_data_get_variant(Eet_Free_Context *context,
4476 memset(&chnk, 0, sizeof(Eet_Data_Chunk)); 4477 memset(&chnk, 0, sizeof(Eet_Data_Chunk));
4477 eet_data_chunk_get(ed, &chnk, p2, size2); 4478 eet_data_chunk_get(ed, &chnk, p2, size2);
4478 4479
4479 if (!chnk.name) 4480 EINA_SAFETY_ON_NULL_GOTO(chnk.name, on_error);
4480 goto on_error;
4481 4481
4482 ret = eet_group_codec[sede->group_type - 100].get 4482 ret = eet_group_codec[sede->group_type - 100].get
4483 (context, ed, sede->subtype, sede, &chnk, sede->type, 4483 (context, ed, sede->subtype, sede, &chnk, sede->type,
4484 sede->group_type, data, &p2, &size2); 4484 sede->group_type, data, &p2, &size2);
4485 4485
4486 if (ret <= 0) 4486 EINA_SAFETY_ON_TRUE_GOTO(ret <= 0, on_error);
4487 goto on_error;
4488 4487
4489/* advance to next chunk */ 4488/* advance to next chunk */
4490 NEXT_CHUNK(p2, size2, chnk, ed); 4489 NEXT_CHUNK(p2, size2, chnk, ed);
@@ -4523,8 +4522,7 @@ eet_data_get_variant(Eet_Free_Context *context,
4523 Eet_Variant_Unknow *evu; 4522 Eet_Variant_Unknow *evu;
4524 4523
4525 evu = calloc(1, sizeof (Eet_Variant_Unknow) + echnk->size - 1); 4524 evu = calloc(1, sizeof (Eet_Variant_Unknow) + echnk->size - 1);
4526 if (!evu) 4525 EINA_SAFETY_ON_NULL_GOTO(evu, on_error);
4527 goto on_error;
4528 4526
4529 evu->size = echnk->size; 4527 evu->size = echnk->size;
4530 memcpy(evu->data, echnk->data, evu->size); 4528 memcpy(evu->data, echnk->data, evu->size);
@@ -4545,6 +4543,7 @@ eet_data_get_variant(Eet_Free_Context *context,
4545 ed, NULL, 4543 ed, NULL,
4546 echnk->data, echnk->size, 4544 echnk->data, echnk->size,
4547 NULL, 0); 4545 NULL, 0);
4546 ERR("ERROR!");
4548 goto on_error; 4547 goto on_error;
4549 } 4548 }
4550 4549