This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PC Lint warning 413:

Hello,

I am having 8052 based project. I am using Keil Microvision 3 compiler and am using PC-Lint for error checking and debugging. I am using absolute memory access macros of Keil for memory mapping in my project, which is as follows:

Project filename is Led.c

#include<Reg52.h> /* Keil header file for 8052 variants */
#include <absacc.h>    /* Include Absolute Memory Access Macro Definitions. this is provided by Keil. The absolute memory access macros allow you to directly access the various memory areas of the 8051. These macros require that you specify the address you wish to read or write */

#define XBYTE ((unsigned char volatile xdata *) 0)
 /* This is provided from the Keil absacc.h file */

#define LED_LATCH XBYTE[0x8600] /* using Absolute Memory Access Macro of Keil*/

#define LEDS_ON    0X00
#define LEDS_OFF   0XFF

unsigned char code led_seq[8] = {0XFE,0XFD,0XFB,0XF7,0xEF,0xDF,0xBF,0x7F};

/* This part of code glows the 8 LEDs one by one(connected thro memory-mapped hardware).*/

        void delay(unsigned int i)
        {
                for(;i>0;i--) ;
        }

        void runLeds(void)
        {
                unsigned char i;

                LED_LATCH = LEDS_OFF;   //Line 35

                for(i=0;i<8;i++)
                {
                        LED_LATCH = led_seq[i];
                        delay(2000);
                }
                LED_LATCH = LEDS_OFF;
        }

        void main(void) /* code starts here */
        {
                --
                --

                while(1)/* SuperLoop that runs forever */
                {
                        --
                        --
                        runLeds();
                        --
                        --
                }
        }


Keil compilation is ok. But, PC-Lint is generating the warning:
" Warning 413: Likely use of null pointer 'unknown-name' in left argument to operator '[' [Reference: file .\Led.c: line 35]

Q: What is the problem with this usage? Is there any other way to use memory-mapping? How to fix this Warning or atleast supress this message?

Parents
  • 1) Why making some requests here and some to http://www.8052.com ? Too many requests,
    so you don't want people to see them all?

    2) Do you notice a problem with writing source code with arbitrarily long source lines? What is
    wrong with splitting your text into multiple lines? /* */ is intended for multi-line comments.
    Many editors can even display a margin on the right (if you don't want to look in the status
    line for the current row/column position), to help you keep track of the line lengths - always
    decide the maximum allowed line length, and then make sure to keep this decision.

    3) Expand your two defines and consider their meaning:
    ((unsigned char volatile xdata *) 0)[0x8600]

    Does the above looks good? Any idea about a better way to access an absolute memory address?

    What is the generic way of typecasting an integer to a pointer?

Reply
  • 1) Why making some requests here and some to http://www.8052.com ? Too many requests,
    so you don't want people to see them all?

    2) Do you notice a problem with writing source code with arbitrarily long source lines? What is
    wrong with splitting your text into multiple lines? /* */ is intended for multi-line comments.
    Many editors can even display a margin on the right (if you don't want to look in the status
    line for the current row/column position), to help you keep track of the line lengths - always
    decide the maximum allowed line length, and then make sure to keep this decision.

    3) Expand your two defines and consider their meaning:
    ((unsigned char volatile xdata *) 0)[0x8600]

    Does the above looks good? Any idea about a better way to access an absolute memory address?

    What is the generic way of typecasting an integer to a pointer?

Children