Page MenuHomePhabricator

warnings in Eet
Open, Incoming QueuePublic

Description

../src/lib/eet/eet_data.c:4176:26: warning: 'union_type' may be used uninitialized in this function [-Wmaybe-uninitialized]

../src/lib/eet/eet_data.c:4380:15: warning: 'union_type' may be used uninitialized in this function [-Wmaybe-uninitialized]

vtorri created this task.Nov 20 2019, 1:39 AM

What compiler are you using?

The first one is an allocation, the second is a strcmp. Both should be harmless.

4102 eet_data_get_union(Eet_Free_Context     *context,
4103                    const Eet_Dictionary *ed,
4104                    Eet_Data_Descriptor  *edd EINA_UNUSED,
4105                    Eet_Data_Element     *ede,
4106                    Eet_Data_Chunk       *echnk,
4107                    int                   type,
4108                    int                   group_type,
4109                    void                 *data,
4110                    char                **p,
4111                    int                  *size)
4112 {
4113    const char *union_type;
4114    void *data_ret = NULL;
4115    int ret = 0;
4116    int i;

(....)

4139         /* Search the structure of the union to decode */
4140         for (i = 0; i < ede->subtype->elements.num; ++i)
4141           if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
4142             {

(....)

4173                /* Set union type. */
4174                if ((!ed) || (!ede->subtype->func.str_direct_alloc))
4175                  {
**4176                     ut = ede->subtype->func.str_alloc(union_type);
4177                     _eet_freelist_str_add(context, ut);
4178                  }
4179                else
4180                  {
4181                     ut = ede->subtype->func.str_direct_alloc(union_type);
4182                     _eet_freelist_direct_str_add(context, ut);
4183                  }
4328 static int
4329 eet_data_get_variant(Eet_Free_Context     *context,
4330                      const Eet_Dictionary *ed,
4331                      Eet_Data_Descriptor  *edd EINA_UNUSED,
4332                      Eet_Data_Element     *ede,
4333                      Eet_Data_Chunk       *echnk,
4334                      int                   type EINA_UNUSED,
4335                      int                   group_type EINA_UNUSED,
4336                      void                 *data,
4337                      char                **p,
4338                      int                  *size)
4339 {
4340    const char *union_type;
4341    void *data_ret = NULL;
4342    int ret = 0;
4343    int i;
4344
4345    /* Read type */
4346    ret = eet_data_get_type(ed,
4347                            EET_T_STRING,
4348                            echnk->data,
4349                            ((char *)echnk->data) + echnk->size,
4350                            &union_type);
4351    EINA_SAFETY_ON_TRUE_GOTO(ret <= 0, on_error);

(....)

4378         /* Search the structure of the union to decode */
4379         for (i = 0; i < ede->subtype->elements.num; ++i)
**4380           if (strcmp(ede->subtype->elements.set[i].name, union_type) == 0)
4381             {
4382                Eet_Data_Element *sede;
4383
4384                /* Yeah we found it ! */
4385                sede = &(ede->subtype->elements.set[i]);
4386
4387                if (sede->group_type != EET_G_UNKNOWN)
4388                  {
4389                     Eet_Data_Chunk chnk;
4390                     char *p2;
4391                     int size2;
4392
4393                     p2 = echnk->data;
4394                     size2 = echnk->size;

gcc for Windows, version 9.2.0. I guess that it does not detect that it is defined there :

https://git.enlightenment.org/core/efl.git/tree/src/lib/eet/eet_data.c#n4123

@segfaultxavi and @lauromoura could you have a look? I think you are the windows guys?

... and just when i thought i've seen the worst of c, strcmp is undefined behaviour with NULL ...

I am definitely not the Windows guy :D

I am definitely not the Windows guy :D

sorry then, I probably mixed you up there.

@ProhtMeyhet if there is no such warning on linux, then we can close the task

@ProhtMeyhet if there is no such warning on linux, then we can close the task

As i said it doesn't look dangerous, but i'd still like someone with experience in C and Windows too look over it. Just in case, because the strcmp could be some sort of quirky bug as it maybe is undefined behaviour. Which would mean any compiler can do as it pleases.