This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/AWR1843BOOST: The initialization of variable j in the function arrangeTracksByAge

Part Number: AWR1843BOOST

Tool/software: Code Composer Studio

Hi,

There is a function called  arrangeTracksByAge in kalman filtering algorithm of the MRR demo.

void arrangeTracksByAge(KFstate_t * restrict TrackList, const uint32_t numTracksTotal)
{
    KFstate_t *  currTrackFwd = &TrackList[0];
    KFstate_t *  currTrackRev = &TrackList[numTracksTotal-1];
    KFstate_t temp;
    uint32_t numTracks = numTracksTotal;
    uint32_t i, j;

    /* For each track, assign the newer tracks to the bottom of the list. Copy the older tracks
     * to the beginning.  */
    for (i = 0; i < numTracksTotal; i++)
    {

       .....

    }

}

In this function the variable j is uninitialized. Is the default value for the uninitialized variable zero in the DSP system?If not, whether the variable j should be initialized as 0.

Thanks,

Regards,

Rata

  • Hi,

    I checked the code. the variable J is initialized in the function as below

    thank you

    Cesar

        /* For each track, assign the newer tracks to the bottom of the list. Copy the older tracks
         * to the beginning.  */
        for (i = 0; i < numTracksTotal; i++)
        {
            if ((currTrackFwd->validity == IS_VALID) && (currTrackFwd->tick < 10))
            {
                for (j = 0; j < numTracks-(i+1); j++)
                {
                    if ((currTrackRev->tick >= 10) && (currTrackFwd->validity == IS_VALID))
                    {
                        temp = * currTrackRev;
                        *currTrackRev = *currTrackFwd;
                        *currTrackFwd = temp;
                        currTrackRev--; j++;
                        break;
                    }
                    else
                    {
                        currTrackRev--;    
                    }
                }
                numTracks -= j;
            }
            
            if (j >= numTracks)
            {
                break;
            }
            currTrackFwd ++ ;
        }
    }

  • Hi Cesar,

      Yes, it is.  The function is as follows:

    void arrangeTracksByAge(KFstate_t * restrict TrackList, const uint32_t numTracksTotal)
    {
        KFstate_t *  currTrackFwd = &TrackList[0];
        KFstate_t *  currTrackRev = &TrackList[numTracksTotal-1];
        KFstate_t temp;
        uint32_t numTracks = numTracksTotal;
        uint32_t i, j;

    /* For each track, assign the newer tracks to the bottom of the list. Copy the older tracks
         * to the beginning.  */
        for (i = 0; i < numTracksTotal; i++)
        {
            if ((currTrackFwd->validity == IS_VALID) && (currTrackFwd->tick < 10))
            {
                for (j = 0; j < numTracks-(i+1); j++)
                {

         ...

            if (j >= numTracks)
            {
                break;
            }
            currTrackFwd ++ ;
        }
    }

    But there is one case that

    (1) for i=0, the condition ((currTrackFwd->validity == IS_VALID) && (currTrackFwd->tick < 10)) is not satisfied,

    (2) at the same time the default value of j is greater than or equal to numTracks (equal to numTracksTotal),

    then the loop for (i = 0; i < numTracksTotal; i++) will be performed only once.

    Then I think the variable j should be initialized as 0 when it is  declared.

    Thanks,

    Regards,

    Rata

  • Hi Rata, 

    It looks like a corner case, and should be fixed. Thank you for finding it. 

    Regards

    Anil

  • Hi Anil,

         Thanks for your reply, I got it.

    BR,

    Rata