Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2020-04-13 16:17:44 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-04-14 19:19:36 +0300
commite7b64cbb172ae94b17f055644cc9b1bda1225288 (patch)
treeed758e53abb9daf174cad10c75d0d2f3ec3b2b0c
parentff414ff895a778df25f4d1b11f304612995c3b10 (diff)
Static code analysis: unconvert
New linter 'unconvert' reports about unneeded type conversions.
-rw-r--r--changelogs/unreleased/ps-linter-unconvert.yml5
-rw-r--r--internal/helper/fstype/detect_linux.go2
-rw-r--r--internal/service/server/disk_stats_test.go4
-rw-r--r--internal/service/server/storage_status_unix.go4
4 files changed, 10 insertions, 5 deletions
diff --git a/changelogs/unreleased/ps-linter-unconvert.yml b/changelogs/unreleased/ps-linter-unconvert.yml
new file mode 100644
index 000000000..1bdb73684
--- /dev/null
+++ b/changelogs/unreleased/ps-linter-unconvert.yml
@@ -0,0 +1,5 @@
+---
+title: 'Static code analysis: unconvert'
+merge_request: 2046
+author:
+type: other
diff --git a/internal/helper/fstype/detect_linux.go b/internal/helper/fstype/detect_linux.go
index 87ef046a9..eda717941 100644
--- a/internal/helper/fstype/detect_linux.go
+++ b/internal/helper/fstype/detect_linux.go
@@ -10,7 +10,7 @@ func detectFileSystem(path string) string {
// This explicit cast to int64 is required for systems where the syscall
// returns an int32 instead.
- fsType, found := magicMap[int64(stat.Type)]
+ fsType, found := magicMap[stat.Type]
if !found {
return unknownFS
}
diff --git a/internal/service/server/disk_stats_test.go b/internal/service/server/disk_stats_test.go
index d2842b186..0d5f766b3 100644
--- a/internal/service/server/disk_stats_test.go
+++ b/internal/service/server/disk_stats_test.go
@@ -58,7 +58,7 @@ func getSpaceStats(t *testing.T, path string) (available int64, used int64) {
require.NoError(t, err)
// Redundant conversions to handle differences between unix families
- available = int64(stats.Bavail) * int64(stats.Bsize)
- used = (int64(stats.Blocks) - int64(stats.Bfree)) * int64(stats.Bsize)
+ available = int64(stats.Bavail) * stats.Bsize
+ used = (int64(stats.Blocks) - int64(stats.Bfree)) * stats.Bsize
return
}
diff --git a/internal/service/server/storage_status_unix.go b/internal/service/server/storage_status_unix.go
index f5b63fc31..e13347cdf 100644
--- a/internal/service/server/storage_status_unix.go
+++ b/internal/service/server/storage_status_unix.go
@@ -16,8 +16,8 @@ func getStorageStatus(shard config.Storage) (*gitalypb.DiskStatisticsResponse_St
}
// Redundant conversions to handle differences between unix families
- available := int64(stats.Bavail) * int64(stats.Bsize)
- used := (int64(stats.Blocks) - int64(stats.Bfree)) * int64(stats.Bsize)
+ available := int64(stats.Bavail) * stats.Bsize
+ used := (int64(stats.Blocks) - int64(stats.Bfree)) * stats.Bsize
return &gitalypb.DiskStatisticsResponse_StorageStatus{
StorageName: shard.Name,