openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libcap/2.27-r0/libcap-2.27/libcap/cap_alloc.c
cap_t cap_init(void)
{
    __u32* raw_data;
    cap_t result;

    raw_data = calloc(1, sizeof(__u32) + sizeof(*result));
    if (raw_data == NULL)
    {
        _cap_debug("out of memory");
        errno = ENOMEM;
        return NULL;
    }

    *raw_data = CAP_T_MAGIC;
    result = (cap_t)(raw_data + 1);

    result->head.version = _LIBCAP_CAPABILITY_VERSION;
    capget(&result->head, NULL); /* load the kernel-capability version */

    switch (result->head.version)
    {
#ifdef _LINUX_CAPABILITY_VERSION_1
        case _LINUX_CAPABILITY_VERSION_1:
            break;
#endif
#ifdef _LINUX_CAPABILITY_VERSION_2
        case _LINUX_CAPABILITY_VERSION_2:
            break;
#endif
#ifdef _LINUX_CAPABILITY_VERSION_3
        case _LINUX_CAPABILITY_VERSION_3:
            break;
#endif
        default: /* No idea what to do */
            cap_free(result);
            result = NULL;
            break;
    }

    return result;
}
/*
 * Obtain a blank set of capabilities
 */
Obtain a blank set of capabilities
Obtain a blank set of capabilities
cap_t cap_init(void)
{
    __u32* raw_data;
    cap_t result;
    raw_data = calloc(1, sizeof(__u32) + sizeof(*result));
    if (raw_data == NULL)
    {
        _cap_debug("out of memory");
        errno = ENOMEM;
        return NULL;
    }
    *raw_data = CAP_T_MAGIC;
    result = (cap_t)(raw_data + 1);
    result->head.version = _LIBCAP_CAPABILITY_VERSION;
    capget(&result->head, NULL); 
    switch (result->head.version)
    {
#ifdef _LINUX_CAPABILITY_VERSION_1
        case _LINUX_CAPABILITY_VERSION_1:
            break;
#endif
#ifdef _LINUX_CAPABILITY_VERSION_2
        case _LINUX_CAPABILITY_VERSION_2:
            break;
#endif
#ifdef _LINUX_CAPABILITY_VERSION_3
        case _LINUX_CAPABILITY_VERSION_3:
            break;
#endif
        default: 
            cap_free(result);
            result = NULL;
            break;
    }
    return result;
}
cap_t cap_init ( void ) { __u32 * raw_data ; cap_t result ; raw_data = calloc ( 1 , sizeof ( __u32 ) + sizeof ( * result ) ) ; if ( raw_data == NULL ) { _cap_debug ( " " ) ; errno = ENOMEM ; return NULL ; } * raw_data = CAP_T_MAGIC ; result = ( cap_t ) ( raw_data + 1 ) ; result -> head . version = _LIBCAP_CAPABILITY_VERSION ; capget ( & result -> head , NULL ) ; switch ( result -> head . version ) { #ifdef _LINUX_CAPABILITY_VERSION_1 case _LINUX_CAPABILITY_VERSION_1 : break ; #endif #ifdef _LINUX_CAPABILITY_VERSION_2 case _LINUX_CAPABILITY_VERSION_2 : break ; #endif #ifdef _LINUX_CAPABILITY_VERSION_3 case _LINUX_CAPABILITY_VERSION_3 : break ; #endif default : cap_free ( result ) ; result = NULL ; break ; } return result ; }
Obtain a blank set of capabilities
Obtain a blank set of capabilities
/* load the kernel-capability version */ /* No idea what to do */