SAI icon indicating copy to clipboard operation
SAI copied to clipboard

GCC 12 error in saimetadatatest.c

Open saiarcot895 opened this issue 1 year ago • 1 comments

With GCC 12, there is a compiler error in saimetadatatest.c generated code. Compiler error:

saimetadatatest.c: In function 'api_name_test':
saimetadatatest.c:6:15: error: dangling pointer 'dummy' to 'ge' may be used [-Werror=dangling-pointer=]
    6 | #define PP(x) printf("%p\n", (x));
      |               ^~~~~~~~~~~~~~~~~~~
saimetadatatest.c:3533:5: note: in expansion of macro 'PP'
 3533 |     PP(dummy);
      |     ^~
saimetadatatest.c:3514:40: note: 'ge' declared here
 3514 |         sai_get_vip_entry_attribute_fn ge = NULL;
      |                                        ^~
cc1: all warnings being treated as errors
make: *** [Makefile:140: saimetadatatest.o] Error 1
        vip_entry_create_fn create = dash_vip_api.create_vip_entry;
        vip_entry_remove_fn remove = dash_vip_api.remove_vip_entry;
        vip_entry_set_fn set = dash_vip_api.set_vip_entry_attribute;
        vip_entry_get_fn get = dash_vip_api.get_vip_entry_attribute;
        sai_create_vip_entry_fn cr = NULL;
        sai_remove_vip_entry_fn re = NULL;
        sai_set_vip_entry_attribute_fn se = NULL;
        sai_get_vip_entry_attribute_fn ge = NULL; // Line 3514
        dummy = &create;
        dummy = &remove;
        dummy = &set;
        dummy = &get;
        dummy = &cr;
        dummy = &re;
        dummy = &se;
        dummy = ≥
        checked[(int)SAI_OBJECT_TYPE_VIP_ENTRY] = SAI_OBJECT_TYPE_VIP_ENTRY;
    }
    int index = SAI_OBJECT_TYPE_NULL;
    for (; index < (int)SAI_OBJECT_TYPE_EXTENSIONS_MAX; ++index)
    {
        printf("checking: %s checked (%d) == index (%d)\n",
             sai_metadata_enum_sai_object_type_t.valuesnames[index],
             checked[index],(sai_object_type_t)index);
        TEST_ASSERT_TRUE(checked[index] == (sai_object_type_t)index, "not all objects were processed");
    }
    PP(dummy); // Line 3533
}

saiarcot895 avatar Apr 16 '24 20:04 saiarcot895

I made attempt to fix this: https://github.com/opencomputeproject/SAI/pull/1996, could you test that ?

kcudnik avatar Apr 17 '24 12:04 kcudnik