i am just using cppcheck the code is working properly just cppcheck gives this errors.
void WorkerThread(WorkBuffer* m_buffer)
{
std::cout << "Thread : " << m_buffer->m_id << ".....Starting" << std::endl;
if (NULL == m_buffer)
std::cout << "Thread : " << m_buffer->m_id << "......work buffer is null" << std::endl;
while(!shut_down_flag)
{
int k = 0;
//Sleep(1);
SleepSystemUsec(100000);
std::cout << "Thread : " << m_buffer->m_id << "....in while loop" << std::endl;
} // of while(!shut_down_flag)
std::cout << "Thread : " << m_buffer->m_id << ".....Request from main thread so ending working thread ...." << std::endl;
};
error : : Possible null pointer dereference: m_buffer - otherwise it is redundant to check it against null.
m_buffer
isNULL
after you've already used it. The message is pointing out (correctly) that if it could beNULL
(and if not, why are you checking?) you should find out before using it in the line above. – Octroi