2

I am using PC Lint and have faced this problem. I have a code something like below:

class A {
public:
    virtual void doSth(int* arg);
}

class B : A {
public: 
    void doSth(int* arg) {...}
}

One of my methods has a pointer parameter. This of course makes PC Lint angry about possible NULL pointer parameter (error 613, which is ok by design, I am not arguing with that). However I know that in my program I never pass a NULL pointer. On the other hand I don't want to disable 613 warnings in the entire method completely so I dropped an idea of using

//lint -efunc(613,*::doSth)

I decided to stick with the -esym(613, arg), +esym(613, arg) wrapping my methods.

What I am considering is is there maybe a more generic approach to this problem using the base class? How to suppress warnings for *arg in virtual doSth() method so it will include all methods from derived classes? Is it possible with PC Lint?

SergeyA
  • 61,605
  • 5
  • 78
  • 137
DvN
  • 21
  • 1
  • Pass things by reference instead of via pointers? –  Jan 16 '18 at 17:07
  • If you never pass NULL consider changing the function to take `int &` – Richard Critten Jan 16 '18 at 17:07
  • In this particular case, if `int arg` is an input parameter, it should never be passed by pointer (or reference), and instead be passed by value. If it is an output parameter, it is better to be returned. – SergeyA Jan 16 '18 at 17:08
  • 1
    @NeilButterworth while `int*` as a single parameter to void function makes no sense, there are cases when pointers are unvoidable. – SergeyA Jan 16 '18 at 17:09
  • Thank you for replies. However that is not the way I am able to fix it. In general I am not able to make that kind of change in code itself. I need to solve it within PC Lint only. :/ – DvN Jan 16 '18 at 17:10

0 Answers0