Bird
0
0

Which of the following is the correct way to use configASSERT() to verify that a pointer ptr is not NULL?

easy📝 Syntax Q3 of 15
FreeRTOS - Debugging and Monitoring
Which of the following is the correct way to use configASSERT() to verify that a pointer ptr is not NULL?
AconfigASSERT(ptr != NULL);
BconfigASSERT(ptr = NULL);
CconfigASSERT(ptr == NULL);
DconfigASSERT(!ptr);
Step-by-Step Solution
Solution:
  1. Step 1: Understand the assertion condition

    The assertion should check that ptr is not NULL, so the condition must be ptr != NULL.
  2. Step 2: Analyze options

    configASSERT(ptr != NULL); correctly uses ptr != NULL. configASSERT(ptr = NULL); uses assignment instead of comparison, which is incorrect. configASSERT(ptr == NULL); checks if ptr is NULL, which is the opposite. configASSERT(!ptr); asserts if ptr is false (NULL), which is incorrect.
  3. Final Answer:

    configASSERT(ptr != NULL); -> Option A
  4. Quick Check:

    Check pointer not NULL with != [OK]
Quick Trick: Use '!=' to check pointer is not NULL [OK]
Common Mistakes:
  • Using assignment '=' instead of comparison '!='
  • Checking for NULL instead of not NULL
  • Using negation incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes