Skip to content

Commit d5a54a2

Browse files
author
lamai93
committed
Replaced flawed null-ptr check by something better. :)
1 parent f1b44fa commit d5a54a2

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

pkg/apis/deployment/v1alpha/image_info.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ func (l *ImageInfoList) AddOrUpdate(info ImageInfo) {
7474

7575
// Equal compares to ImageInfo
7676
func (i *ImageInfo) Equal(other *ImageInfo) bool {
77-
if i == other {
78-
return true
79-
} else if i == nil {
77+
if i == nil || other == nil {
8078
return false
79+
} else if i == other {
80+
return true
8181
}
8282

8383
return i.ArangoDBVersion == other.ArangoDBVersion &&

pkg/apis/deployment/v1alpha/secret_hashes.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ type SecretHashes struct {
3838

3939
// Equal compares two SecretHashes
4040
func (sh *SecretHashes) Equal(other *SecretHashes) bool {
41-
if sh == other {
42-
return true
43-
} else if sh == nil {
41+
if sh == nil || other == nil {
4442
return false
43+
} else if sh == other {
44+
return true
4545
}
4646

4747
return sh.AuthJWT == other.AuthJWT &&

pkg/util/times.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ func TimeCompareEqual(a, b metav1.Time) bool {
3535

3636
// TimeCompareEqualPointer compares two times, allowing an error of 1s
3737
func TimeCompareEqualPointer(a, b *metav1.Time) bool {
38-
if a == b {
39-
return true
40-
} else if a == nil {
38+
if a == nil || b == nil {
4139
return false
40+
} else if a == b {
41+
return true
4242
}
4343

4444
return TimeCompareEqual(*a, *b)

0 commit comments

Comments
 (0)