Can I remove NULL and bounds checks if I use SAL?

82 views Asked by At

How much can I rely on SAL? Do I need to do

NSTATUS my_func(_In_ int *p)
{
    if (NULL == p) {
        return STATUS_INVALID_PARAMETER;
    }
    *p = 1;
    return STATUS_SUCCESS;
}

or can I just do

NTSTATUS my_func(_In_ int *p)
{
    *p = 1;
    return STATUS_SUCCESS;
}
1

There are 1 answers

1
Reilly Grant On BEST ANSWER

SAL only provides static checks at compile time. This assumes that all code involved has the appropriate annotations and has also been checked. This is okay internal to your application or module but be careful at boundaries with other libraries.