Bird
0
0

Which of the following is the correct syntax to use configASSERT() to check if a pointer ptr is not NULL?

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

    We want to assert that the pointer is NOT NULL, so the condition should be true when ptr is valid.
  2. Step 2: Analyze each option

    configASSERT(ptr != NULL); checks ptr != NULL, which is correct. configASSERT(ptr == NULL); checks ptr == NULL (wrong), C uses assignment (=) which is a syntax error, and D checks ptr as a boolean but is less explicit.
  3. Final Answer:

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

    Check pointer not NULL with ptr != NULL [OK]
Quick Trick: Use != NULL to assert pointer is valid, not == NULL [OK]
Common Mistakes:
  • Using assignment (=) instead of comparison (== or !=)
  • Checking for NULL instead of not NULL
  • Relying on implicit pointer truthiness

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes