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 6.0.1 : Variable set but never used.



Hi,

I am using CCS version 6.0.1.

I am declaring a variable within a function i.e. making it a local variable .I am using that variable in the same function. But still I am getting following error message :

#552-D variable "variableName" was set but never used.

Is this is a compiler issue or linking problem ?

Thanks in advance.

Regards,

Vivek

  • It’s not an ‘Error’ but just a ‘Warning’ that you have load a value into your variable but never read from it, or the place where you read from it is unreachable.
  • Hi Leo,

    Thanks for your reply.

    I agree it's a warning. To check your concern, I used that variable just after declaring it. Still I am getting the same warning.

    Regards,
    Vivek
  • Then post that code here and I can have a look.
  • //Common parameters for every packet
    	_u8			 uc_packet_Identifier = 0;
    	_u8			 uc_communication_Type; // NA as of now
    	_u8			 uc_payLoadDataLength_Rx;
    	_u8			 uc_payLoadDataLength_Tx;
    	_u8			 uc_checkSum_Rx;
    	_u8			 uc_checkSum_Tx;
    
    	// Specific to Scan room option
    	//Rx
    	_u8 		 uc_scanCommand;
    	//Tx
    	_u8	         uc_numberOfRooms;
    
    	//Specific to Room selection
    	_u8	        uc_roomNumber = 0;
    	_u8		uc_switchStatus = 0;
    
    	//Specific to Switch operation
    	_u8               uc_switchNumber = 0;
    	_u8	        uc_switchControlByte = 0;
    
    
    	_u8 		uc_txBufferSize = 0;
    
    	while(1)
          {
                for(LoopCount = 0; LoopCount < 6 ; LoopCount++)
    		{
    			Status = sl_Recv(newSockID, &(packetHeader[LoopCount]), 1, 0);
    
    			if( Status <= 0 )
    			{
    				sl_Close(newSockID);
    				sl_Close(SockID);
    				CLI_Write(" [TCP Server] Data recv Error \n\r");
    				ASSERT_ON_ERROR(TCP_RECV_ERROR);
    			}
    		}
    
    		uc_payLoadDataLength_Rx = packetHeader[5];
    		uc_packet_Identifier = packetHeader[0];
    		uc_communication_Type = packetHeader[1];
    
    		for(LoopCount = 0; LoopCount < uc_payLoadDataLength_Rx ; LoopCount++)
    		{
    			Status = sl_Recv(newSockID, &(packetDetail[LoopCount]),1,0);
    
    			if( Status <= 0 )
    			{
    				sl_Close(newSockID);
    				sl_Close(SockID);
    				CLI_Write(" [TCP Server] Data recv Error \n\r");
    				ASSERT_ON_ERROR(TCP_RECV_ERROR);
    			}
    			if(LoopCount == uc_payLoadDataLength_Rx)
    			{
    				toggleLed(1);
    			}
    		}
    
    		for(LoopCount = 0; LoopCount < 5; LoopCount++ )
    		{
    			packet_Tx[LoopCount] = packetHeader[LoopCount];
    		}
    
    		switch(uc_packet_Identifier)
    		{
    
    		case 0x02 :
    			uc_scanCommand = packetDetail[0];
    			uc_checkSum_Rx = packetDetail[1];
    
    			
    			uc_numberOfRooms = MAX_NUM_ROOMS;
    
    			uc_payLoadDataLength_Tx = 2 + MAX_NUM_ROOMS;
    
    			packet_Tx[5] = uc_payLoadDataLength_Tx;
    			packet_Tx[6] = uc_numberOfRooms;
    
    			for(uc_numberOfRooms = 7; uc_numberOfRooms < MAX_NUM_ROOMS; uc_numberOfRooms++)
    			{
    				packet_Tx[uc_numberOfRooms] = 0x01 + uc_numberOfRooms;
    			}
    
    			uc_txBufferSize	= uc_numberOfRooms+1;
    			//!Checksum calulation to be done
    
    
    			break;
                     case 0x03 :
    

    I have removed unnecessary portion of the code. Just for your convince. 

    Here following variables showing with the mentioned error message:

    1. uc_communication_Type
    2. uc_checkSum_Rx
    3. uc_scanCommand

    Although, these variables have been used in code.

    Regards,

    Vivek

  • ‘uc_communication_Type’ is commented as NA, you only write a value to it but never reads from (uses this value), therefore the warning that you are wasting RAM. Same for ‘uc_checkSum_Rx’ and ‘uc_scanCommand’.
  • Hi Leo,

    Thanks a lot.

    Understood the point.

    Regards,
    Vivek

**Attention** This is a public forum