﻿# V8017\. The conditions of two adjacent 'if' statements are equivalent\.

The analyzer has detected code that contains two adjacent if statements with identical conditions\. This is either a potential error or redundant code\.

```cpp
func Logging(s1 *string, s2 *string) {
  if s1 != nil {
    fmt.Println(*s1)
  }
  if s1 != nil {
    fmt.Println(*s2)
  }
}
```

The code contains an error in the second condition\. The `s1` variable is checked twice when `s2` should be checked instead\.

The fixed code: 

```cpp
func Logging(s1 *string, s2 *string) {
  if s1 != nil {
    fmt.Println(*s1)
  }
  if s2 != nil {
    fmt.Println(*s2)
  }
}
```

This warning does not always mean there is an error in the code\. It may be redundant:

```cpp
func Logging2(toFile bool, s1 string, s2 string) {
  if toFile {
    fmt.Println(s1)
  }
  if toFile {
    fmt.Println(s2)
  }
}
```

The code is correct but slightly inefficient because it checks the value of the same boolean variable twice\. It can be rewritten as follows:

```cpp
func Logging2(toFile bool, s1 string, s2 string) {
  if toFile {
    fmt.Println(s1)
    fmt.Println(s2)
  }
}
```