xNotificationResult error

Hi,
In the code below I declare the variable xNotificationResult and I use it in several points within that function like I’ve done hundreds of times in the rest of the code. But in this function the compiler give the error shown here below (variable set but not used) which does not make sense - and if I comment out the variable then it complaints that the variable is not declared:

make[2]: Entering directory 'C:/RationalTest/Firmware_NEW/firmware/Firmware_NEW_TEST_ON_C.X'
"C:\Program Files\Microchip\xc32\v2.50\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MZ1024EFG100  -ffunction-sections -O1 -I"../src" -I"../src/config/default" -I"../src/third_party/rtos/FreeRTOS/Source/include" -I"../src/third_party/rtos/FreeRTOS/Source/portable/MPLAB/PIC32MZ" -Werror -Wall -MP -MMD -MF "build/default/production/_ext/1360937237/task_tph_control.o.d" -o build/default/production/_ext/1360937237/task_tph_control.o ../src/task_tph_control.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files/Microchip/MPLABX/v5.50/packs/Microchip/PIC32MZ-EF_DFP/1.3.58"  
../src/task_tph_control.c: In function 'TASK_TPH_CONTROL_Tasks':
../src/task_tph_control.c:319:15: error: variable 'xNotificationResult' set but not used [-Werror=unused-but-set-variable]
     uint32_t  xNotificationResult = 0;
               ^

and this is the code:


void TASK_TPH_CONTROL_Tasks ( void )
{
    uint32_t ui32_CurrentNotificationValue = 0; 
    BaseType_t xNotificationResult = 0;

    /* Check the application's current state. */
    switch ( task_tph_controlData.state)
    {
        /* Application's initial state. */
        case TASK_TPH_CONTROL_STATE_INIT:
        {

            //TODO: maybe turn TPH power on here
            task_tph_controlData.state = TASK_TPH_CONTROL_STANDBY;
            //increase programmatically task priority to 3 in INIT state
            vTaskPrioritySet(NULL, 3);
            break;
        }

        case TASK_TPH_CONTROL_STANDBY:
        {
            //Block until event from PRINT task to print a label
            xNotificationResult = xTaskNotifyWait(0, 
                                                    NOTIF__BIT__TPH__START_LOADING_IMAGE_LINE_INTO_TPH, 
                                                    &ui32_CurrentNotificationValue, 
                                                    portMAX_DELAY);            
            //if the correct one change state
            if ((ui32_CurrentNotificationValue & NOTIF__BIT__TPH__START_LOADING_IMAGE_LINE_INTO_TPH) != 0)  
            {
                Change_TPH_Control_State_To(TASK_TPH_CONTROL_SHIFTING_DATA_ENTER);
                SYS_DEBUG_MESSAGE(SYS_ERROR_INFO, "TPH CTRL - Changed state to TASK_TPH_CONTROL_SHIFTING_DATA_ENTER\r\n");
            }            
            break;
            
        }

        case TASK_TPH_CONTROL_SHIFTING_DATA_ENTER:                //TODO CHECK... count the lines here... instead of counting the +80 dytes of reading the array... maybe increase only here because need to stop immediately on last falling edge?
        {   
            //effectively this is executed/entered once per image/label at the very start of image/label printing
            //initialise the variables
            Set_CurrentLineCounter(xPrinterData._HOST_ui32_LabelLength_InDots);  //decremented every full line. Decides when image print is completes 
            Set_MotorStepsBetweenStrobes(TPH_CONTROL__MOTOR_STEPS_BETWEEN_STROBES);  // 
            Set_StrobesCyclesPerDotLine(TPH_CONTROL__STROBES_PER_LINE);
            
            //change state
            Change_TPH_Control_State_To(TASK_TPH_CONTROL_SHIFTING_DATA);
            SYS_DEBUG_MESSAGE(SYS_ERROR_INFO, "TPH CTRL - Changed state to TASK_TPH_CONTROL_SHIFTING_DATA\r\n");
            break;
                    
        }
        
        case TASK_TPH_CONTROL_SHIFTING_DATA:
        {
            ShiftImageBufferLineIntoTPH();
            LatchData();
            //Block until event from OCOMP FALLING EDGE which notifies time to start STRB. 
            //The OCOMP high period must be longer than the data shifting PLUS LATCH... TODO HIGH ensure this is the case with logic analyser
            xNotificationResult = xTaskNotifyWait(0, 
                                                    NOTIF__BIT__TPH__IMAGE_LINE_STROBE_START, 
                                                    &ui32_CurrentNotificationValue, 
                                                    portMAX_DELAY);            
            //if the correct one change state
            if ((ui32_CurrentNotificationValue & NOTIF__BIT__TPH__IMAGE_LINE_STROBE_START) != 0)  
            {
                Change_TPH_Control_State_To(TASK_TPH_CONTROL_STROBING);
                SYS_DEBUG_MESSAGE(SYS_ERROR_INFO, "TPH CTRL - Changed state to TASK_TPH_CONTROL_STROBING\r\n");
            }            
            break;
        }

        case TASK_TPH_CONTROL_STROBING:
        {
            //TPH_Strobe_1();   //TODO HIGH choose single or dual strobe. No need to wait between the two STRB
            //TPH_Strobe_2(); 
            TPH_Strobe_1_And_2(); 
            taskENTER_CRITICAL();
            task_printData.ui32_StrobesCyclesPerDotLine--;   
            taskEXIT_CRITICAL();
            Change_TPH_Control_State_To(TASK_TPH_CONTROL_STROBING_WAIT_FOR_NEXT_PARTIAL_DOT_LINE);
            SYS_DEBUG_MESSAGE(SYS_ERROR_INFO, "TPH CTRL - Changed state to TASK_TPH_CONTROL_STROBING_WAIT_FOR_NEXT_PARTIAL_DOT_LINE\r\n");
            break;
        }
        
        case TASK_TPH_CONTROL_STROBING_WAIT_FOR_NEXT_PARTIAL_DOT_LINE: 
        {
            
            //Block until event from OCOMP FALLING EDGE which notifies time to start STRB. 
            //The OCOMP high period must be longer than the data shifting PLUS LATCH... TODO HIGH ensure this is the case with logic analyser
            xNotificationResult = xTaskNotifyWait(0, 
                                                NOTIF__BIT__TPH__IMAGE_LINE_SINGLE_STROBE_CYCLE_COMPLETE, 
                                                &ui32_CurrentNotificationValue, 
                                                portMAX_DELAY);            
            //if the correct one change state
            if ((ui32_CurrentNotificationValue & NOTIF__BIT__TPH__IMAGE_LINE_SINGLE_STROBE_CYCLE_COMPLETE) != 0)  
            {
                if (task_printData.ui32_StrobesCyclesPerDotLine > 0)
                {
                    Change_TPH_Control_State_To(TASK_TPH_CONTROL_STROBING);
                    SYS_DEBUG_MESSAGE(SYS_ERROR_INFO, "TPH CTRL - Changed state to TASK_TPH_CONTROL_STROBING\r\n");
                }
                else
                {
                    Change_TPH_Control_State_To(TASK_TPH_CONTROL_STROBING_FULL_DOT_LINE_PRINTED);
                    SYS_DEBUG_MESSAGE(SYS_ERROR_INFO, "TPH CTRL - Changed state to TASK_TPH_CONTROL_STROBING_FULL_DOT_LINE_PRINTED\r\n");
                }
            } 
            break;
        }
    
        case TASK_TPH_CONTROL_STROBING_FULL_DOT_LINE_PRINTED:
        {
            Change_TPH_Control_State_To(TASK_TPH_CONTROL_STANDBY);
            SYS_DEBUG_MESSAGE(SYS_ERROR_INFO, "TPH CTRL - Changed state to TASK_TPH_CONTROL_STANDBY\r\n");
            break;
        }
        
        default:
        {
            _nop();
        }
    }
}

Thank you
Rick

Sorry, I just noticed that I am not testing for that variable after reading it… :roll_eyes: :roll_eyes: