Search code examples
cbuildwarningsavratmega

Linker warning after builds with CodevisionAVR for ATmega16a


this code is c language and should be builds for ATmega16a I use Codevision to build it but I have this warning but I cant find why. I tried different way to test that but I still give this warning. what should I do ?

Linker warning: function 'UserIdentify' not used in data stack usage calculation due to possible recursive calls

void main(void)
{
    DDRC = 0x07;
    DDRD = 0x78;
    PORTD = 0x07;

    lcd_init(20);

    if (UL == -1)
    {
        UL = 1;
        user[0].role = true;
        user[0].username = 123;
        user[0].password = 321;
    }

    while (1)
    {
        UserIdentify();
    }
}

void UserIdentify(void)
{
    username = 0;
    password = 0;
    checker = true;
    lcd_clear();
    lcd_putsf("Welcome");
    lcd_gotoxy(0, 1);
    lcd_putsf("Login press 1");
    lcd_gotoxy(0, 2);
    lcd_putsf("Register press 2");
    lcd_gotoxy(0, 3);
    lcd_putsf("About this device 3");

    switch (ScanKey())
    {
    case 1:
        lcd_clear();
        lcd_putsf("Enter Username : ");
        lcd_gotoxy(0, 1);
        username = ScanKey();
        lcd_gotoxy(0, 2);
        lcd_putsf("Enter Password : ");
        lcd_gotoxy(0, 3);
        password = ScanKey();

        for (i = 0; i < UL; i++)
        {
            if (user[i].username == username)
            {
                if (user[i].password == password)
                {
                    PORTC .0 = 1;
                    lcd_clear();
                    lcd_putsf("You Entered !!");
                    delay_ms(150);
                    PORTC .0 = 0;
                    if (user[i].role == false)
                    {
                        UserPannel(i);
                        break;
                    }
                    else if (user[i].role == true)
                    {
                        AdminPannel(i);
                        break;
                    }
                }
            }
        }
        if (checker)
        {
            PORTC .1 = 1;
            lcd_clear();
            lcd_putsf("Wrong User or Pass !");
            delay_ms(150);
            PORTC .1 = 0;
        }
        break;

    case 2:
        EditUser(5, -1);
        UserPannel(UL - 1);
        break;

    case 3:
        EditUser(8, -1);
        break;

    default:
        break;
    }
}

void EditUser(int Case, int Code)
{
    switch (Case)
    {
    case 1:
        lcd_clear();
        lcd_putsf("Enter new Username:");
        lcd_gotoxy(0, 1);
        user[Code].username = ScanKey();
        lcd_gotoxy(0, 2);
        PORTC .0 = 1;
        lcd_putsf("Username changed.");
        delay_ms(150);
        PORTC .0 = 0;
        break;

    case 2:
        lcd_clear();
        lcd_putsf("Enter new Password:");
        lcd_gotoxy(0, 1);
        user[Code].password = ScanKey();
        lcd_gotoxy(0, 1);
        PORTC .0 = 1;
        lcd_putsf("Password changed.");
        delay_ms(150);
        PORTC .0 = 0;
        break;

    case 3:
        lcd_clear();
        for (i = Code; i < UL; i++)
        {
            user[Code] = user[Code + 1];
        }
        UL--;
        PORTC .0 = 1;
        lcd_putsf("User Deleted.");
        delay_ms(150);
        PORTC .0 = 0;
        UserIdentify();
        break;

    case 4:
        checker = false;
        break;

    case 5:
        if (UL != 10)
        {
            do
            {
                lcd_clear();
                lcd_putsf("Enter Username :");
                lcd_gotoxy(0, 1);
                user[UL].username = ScanKey();

                lcd_gotoxy(0, 2);
                lcd_putsf("Enter Password :");
                lcd_gotoxy(0, 3);
                user[UL].password = ScanKey();
            } while (user[UL].username == 0 || user[UL].password == 0);

            lcd_clear();
            if (user[Code].role == true)
            {
                lcd_putsf("Promote to admin ? ");
                lcd_gotoxy(0, 1);
                lcd_putsf("Yes press 1");
                lcd_gotoxy(0, 2);
                lcd_putsf("No press 2");
                if (ScanKey() == 1)
                {
                    user[UL].role = true;
                }
                else
                {
                    user[UL].role = false;
                }
                lcd_gotoxy(0, 3);
            }
            UL++;
            PORTC .0 = 1;
            lcd_putsf("User added !!");
            delay_ms(150);
            PORTC .0 = 0;
        }
        else
        {
            PORTC .1 = 1;
            lcd_clear();
            lcd_putsf("Users full !!");
            delay_ms(150);
            PORTC .1 = 0;
        }

        break;

    case 6:
        if (user[Code].role == true)
        {
            lcd_clear();
            lcd_putsf("Promote to admin ?");
            lcd_gotoxy(0, 1);
            lcd_putsf("Yes press 1");
            lcd_gotoxy(0, 2);
            lcd_putsf("No press 2");
            if (ScanKey() == 1)
            {
                PORTC .0 = 1;
                user[Code].role = true;
                lcd_gotoxy(0, 3);
                lcd_putsf("Promoted !");
                delay_ms(150);
                PORTC .0 = 0;
            }
            else
            {
                PORTC .1 = 1;
                lcd_gotoxy(0, 3);
                lcd_putsf("Cancelled !");
                delay_ms(150);
                PORTC .1 = 0;
            }
        }
        break;

    case 7:
        if (user[Code].role == true)
        {
            lcd_clear();
            lcd_putsf("Demote admin ?");
            lcd_gotoxy(0, 1);
            lcd_putsf("Yes press 1");
            lcd_gotoxy(0, 2);
            lcd_putsf("No press 2");
            if (ScanKey() == 1)
            {
                PORTC .0 = 1;
                user[Code].role = false;
                lcd_gotoxy(0, 3);
                lcd_putsf("Demoted !");
                delay_ms(150);
                PORTC .0 = 0;
            }
            else
            {
                PORTC .1 = 1;
                lcd_gotoxy(0, 3);
                lcd_putsf("Cancelled !");
                delay_ms(150);
                PORTC .1 = 0;
            }
        }
        break;

    case 8:
        lcd_clear();
        lcd_putsf("DIGITAL PASS LOCK");
        lcd_gotoxy(0, 1);
        lcd_putsf("Admins & users");
        lcd_gotoxy(0, 2);
        lcd_putsf("admin can edit users");
        lcd_gotoxy(0, 3);
        lcd_putsf("Prgrmd & bld Zavosh");
        ScanKey();

    default:
        break;
    }
}

void UserPannel(int UserCode)
{
    while (checker)
    {
        lcd_clear();
        sprintf(show, "User %d", user[UserCode].username);
        lcd_puts(show);
        lcd_gotoxy(0, 1);
        lcd_putsf("chng Username prs 1");
        lcd_gotoxy(0, 2);
        lcd_putsf("chng Password prs 2");
        lcd_gotoxy(0, 3);
        lcd_putsf("Delete 3 - Logout 4");

        EditUser(ScanKey(), UserCode);
    }
}

void AdminPannel(int AdminCode)
{
    while (checker)
    {
        lcd_clear();
        sprintf(show, "%d Users", UL);
        lcd_puts(show);
        lcd_gotoxy(0, 1);
        lcd_putsf("Edit Profile prss 1");
        lcd_gotoxy(0, 2);
        lcd_putsf("Edit Users prss 2");
        lcd_gotoxy(0, 3);
        lcd_putsf("Add Users prss 3");

        switch (ScanKey())
        {
        case 1:
            UserPannel(AdminCode);
            break;

        case 2:
            lcd_clear();
            lcd_putsf("Enter Username :");
            username = ScanKey();

            for (i = 0; i < UL; i++)
            {
                if (user[i].username == username)
                {
                    checker = false;
                    lcd_clear();
                    lcd_putsf("Username 1, Pass 2");
                    lcd_gotoxy(0, 1);
                    lcd_putsf("Logout 4, Delete 3");

                    if (user[i].role)
                    {
                        lcd_gotoxy(0, 2);
                        lcd_putsf("Demote admin 7");
                        EditUser(ScanKey(), i);
                    }
                    else
                    {
                        lcd_gotoxy(0, 2);
                        lcd_putsf("Promote Admin 6");
                        user[i].role = true;
                        EditUser(ScanKey(), i);
                        user[i].role = true;
                    }

                    break;
                }
            }
            if (checker)
            {
                PORTC .1 = 1;
                lcd_clear();
                lcd_putsf("User Not Found !!");
                delay_ms(150);
                PORTC .1 = 0;
            }
            else
            {
                checker = true;
            }
            break;

        case 3:
            EditUser(5, AdminCode);
            break;

        default:
            break;
        }
    }
}

Solution

  • Linker warning: function 'UserIdentify' not used in data stack usage calculation due to possible recursive calls

    This message tells you that the compiler is unable to estimate the data stack usage of your code because it detected a possible recursive call. In case of recursive call, stack use depends on the data values at run-time so the compiler doesn't know it.