Bird
0
0

Examine this code snippet:

medium📝 Debug Q6 of 15
FreeRTOS - Debugging and Monitoring
Examine this code snippet:
int *ptr = NULL;
configASSERT(ptr = NULL);

What is the main issue causing unexpected behavior?
AThe assertion uses assignment '=' instead of comparison '==', causing the condition to always be false.
BThe pointer is initialized incorrectly; it should not be NULL.
CconfigASSERT() cannot be used with pointers.
DThe assertion condition is correct; no issue exists.
Step-by-Step Solution
Solution:
  1. Step 1: Identify the operator used

    The code uses ptr = NULL inside configASSERT(), which is an assignment, not a comparison.
  2. Step 2: Effect of assignment in assertion

    Assignment returns the assigned value (NULL), which evaluates to false, causing the assertion to fail every time.
  3. Final Answer:

    The assertion uses assignment '=' instead of comparison '==', causing the condition to always be false. -> Option A
  4. Quick Check:

    Assignment used instead of comparison [OK]
Quick Trick: Use '==' for comparison, not '=' [OK]
Common Mistakes:
  • Confusing assignment '=' with equality '=='
  • Assuming pointer initialization causes assertion failure
  • Believing configASSERT can't check pointers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More FreeRTOS Quizzes