﻿# V561\. Consider assigning value to 'foo' variable instead of declaring it anew\.

The analyzer detected a potential error: there is a variable in code which is defined and initialized but not being used further\. Besides, there is a variable in the exterior scope which also has the same name and type\. It is highly probable that the programmer intended to use an already existing variable instead of defining a new one\.

Let's examine this sample:

```cpp
BOOL ret = TRUE;
if (m_hbitmap)
  BOOL ret = picture.SaveToFile(fptr);
```

The programmer defined a new variable 'ret' by accident, which causes the previous variable to always have the TRUE value regardless if the picture is saved into a file successfully or not\. This is the correct code:

```cpp
BOOL ret = TRUE;
if (m_hbitmap)
  ret = picture.SaveToFile(fptr);
```