Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

potentially uninitialized local pointer variable - Understand but does not make sense

$
0
0
What have I done incorrectly?

I received the following error while building my project: potentially uninitialized local pointer variable **

I understand what the error says, but it doesn't make sense to me.
I don't see how the statement marked with ** can be reached if output is not opened

The variable log was initialed prior to invoking this function and was was passed to it.
If log is positive, output is opened, if not, it is not opened, nor can the line which it referenced in the line marked with ** be reached.

Code:

int TaskToDo(const unsigned char* in, //pointer to the input buffer
        unsigned char* out,                    //pointer to the output buffer
        unsigned long length,                    //text length
        __m128i* schedule,                    //pointer to the expanded schedule
        int number_of_rounds,          //number of rounds
        BOOL log)                                  //log output
{
        __m128i tmp;
        int i, j;
        FILE* output;

        if (log)
        {
                if (fopen_s(&output, "C://Data/mytext.txt", "a") == 0)
                    fprintf_s(output, "File was opened for input!\n");
                else
                {
                        AfxMessageBox(L"File could not be opened!\n");
                        exit(1);
                }
        }

        if (log)
        {
**            fprintf_s(output, "Text to be written: ");

              for (int k = 0; k < length * 16; k++)
              fprintf_s(output, "%X ", in[k]);
              fprintf_s(output, "\r\n");
        }
              //other code deleted
}//end int TaskToDo(const unsigned char*


Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images