static int _CheckMaxValue()

in LCM/codec/mof/parser/types.c [4209:4453]


static int _CheckMaxValue(
    void * mofstate,
    const MI_PropertyDecl* pd,
    const MI_Qualifier* q)
{
    MI_Sint64 r;
    MI_Uint32 i;
    MOF_State * state = (MOF_State *)mofstate;
    switch (pd->type)
    {
        case MI_UINT8:
        case MI_SINT8:
        case MI_UINT16:
        case MI_SINT16:
        case MI_UINT32:
        case MI_SINT32:
        case MI_UINT64:
        case MI_REAL32:
        case MI_REAL64:
        case MI_SINT64:
        case MI_UINT8A:
        case MI_SINT8A:
        case MI_UINT16A:
        case MI_SINT16A:
        case MI_UINT32A:
        case MI_SINT32A:
        case MI_UINT64A:
        case MI_SINT64A:
        case MI_REAL32A:
        case MI_REAL64A:
            break;
        default:
            goto incompatibleError;
    }

    if (!q->value || !pd->value)
        return 0;

    r = *((MI_Sint64*)q->value);

    switch (pd->type)
    {
        case MI_UINT8:
        {
            MI_Uint8 x = *((MI_Uint8*)pd->value);
            if ((MI_Sint64)x > r)
                goto constraintError;
            break;
        }
        case MI_SINT8:
        {
            MI_Sint8 x = *((MI_Sint8*)pd->value);
            if ((MI_Sint64)x > r)
                goto constraintError;
            break;
        }
        case MI_UINT16:
        {
            MI_Uint16 x = *((MI_Uint16*)pd->value);
            if ((MI_Sint64)x > r)
                goto constraintError;
            break;
        }
        case MI_SINT16:
        {
            MI_Sint16 x = *((MI_Sint16*)pd->value);
            if ((MI_Sint64)x > r)
                goto constraintError;
            break;
        }
        case MI_UINT32:
        {
            MI_Uint32 x = *((MI_Uint32*)pd->value);
            if ((MI_Sint64)x > r)
                goto constraintError;
            break;
        }
        case MI_SINT32:
        {
            MI_Sint32 x = *((MI_Sint32*)pd->value);
            if ((MI_Sint64)x > r)
                goto constraintError;
            break;
        }
        case MI_UINT64:
        {
            MI_Uint64 x = *((MI_Uint64*)pd->value);
            if (x > (MI_Uint64)r)
                goto constraintError;
            break;
        }
        case MI_SINT64:
        {
            MI_Sint64 x = *((MI_Sint64*)pd->value);
            if ((MI_Sint64)x > r)
                goto constraintError;
            break;
        }
        case MI_REAL32:
        {
            MI_Real32 x = *((MI_Real32*)pd->value);
            if (x > (MI_Real32)r)
                goto constraintError;
            break;
        }
        case MI_REAL64:
        {
            MI_Real64 x = *((MI_Real64*)pd->value);
            if (x > (MI_Real64)r)
                goto constraintError;
            break;
        }
        case MI_UINT8A:
        {
            MI_Uint8A x = *((MI_Uint8A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if ((MI_Uint8)x.data[i] > r)
                    goto constraintError;
            }
            break;
        }
        case MI_SINT8A:
        {
            MI_Sint8A x = *((MI_Sint8A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if ((MI_Sint8)x.data[i] > r)
                    goto constraintError;
            }
            break;
        }
        case MI_UINT16A:
        {
            MI_Uint16A x = *((MI_Uint16A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if ((MI_Uint16)x.data[i] > r)
                    goto constraintError;
            }
            break;
        }
        case MI_SINT16A:
        {
            MI_Sint16A x = *((MI_Sint16A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if ((MI_Sint16)x.data[i] > r)
                    goto constraintError;
            }
            break;
        }
        case MI_UINT32A:
        {
            MI_Uint32A x = *((MI_Uint32A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if ((MI_Uint32)x.data[i] > r)
                    goto constraintError;
            }
            break;
        }
        case MI_SINT32A:
        {
            MI_Sint32A x = *((MI_Sint32A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if ((MI_Sint32)x.data[i] > r)
                    goto constraintError;
            }
            break;
        }
        case MI_UINT64A:
        {
            MI_Uint64A x = *((MI_Uint64A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if ((MI_Sint64)x.data[i] > r)
                    goto constraintError;
            }
            break;
        }
        case MI_SINT64A:
        {
            MI_Sint64A x = *((MI_Sint64A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if ((MI_Sint64)x.data[i] > r)
                    goto constraintError;
            }
            break;
        }
        case MI_REAL32A:
        {
            MI_Real32A x = *((MI_Real32A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if (x.data[i] > (MI_Real32)r)
                    goto constraintError;
            }
            break;
        }
        case MI_REAL64A:
        {
            MI_Real64A x = *((MI_Real64A*)pd->value);

            for (i = 0; i < x.size; i++)
            {
                if (x.data[i] > (MI_Real64)r)
                    goto constraintError;
            }
            break;
        }
        default:
            goto incompatibleError;
    }

    return 0;

constraintError:
    yyerrorf(state->errhandler, 
        ID_PROPERTY_CONSTRAINT_FAILURE,
        "",
        tcs(pd->name), 
        tcs(q->name));
    return -1;

incompatibleError:
    yyerrorf(state->errhandler, 
        ID_PROPERTY_QUALIFIER_INCOMPATIBLE,
        "",
        tcs(q->name), 
        tcs(pd->name),
        _getTypeName_MI((MI_Type)pd->type));
    return -1;
}