From 26731e232a72196a576282a400b3a1001f6ded74 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 7 Jan 2025 14:42:17 +0100 Subject: [PATCH] build: depend on go1.21 go1.19 is not supported anymore, and certain packages (at least aws-sdk-go-v2) require go1.21 or newer. Revive complains about the use of `max` as variable name. go1.21 contains the `max()` function, so it is better to rename the variable. Signed-off-by: Niels de Vos --- go.mod | 2 +- internal/retry/sizer.go | 10 ++++----- rbd/mirror.go | 48 ++++++++++++++++++++--------------------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/go.mod b/go.mod index 53867a1427..0196b32151 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ceph/go-ceph -go 1.19 +go 1.21 require ( github.com/aws/aws-sdk-go v1.55.5 diff --git a/internal/retry/sizer.go b/internal/retry/sizer.go index 5b27e51030..df427cf03e 100644 --- a/internal/retry/sizer.go +++ b/internal/retry/sizer.go @@ -43,13 +43,13 @@ type SizeFunc func(size int) (hint Hint) // DoubleSize or indicating a size not greater than the current size, the size // is doubled. If the hint or next size is greater than the max size, the max // size is used for a last retry. -func WithSizes(size int, max int, f SizeFunc) { - if size > max { +func WithSizes(size int, maxSize int, f SizeFunc) { + if size > maxSize { return } for { hint := f(size) - if hint == nil || size == max { + if hint == nil || size == maxSize { break } if hint.size() > size { @@ -57,8 +57,8 @@ func WithSizes(size int, max int, f SizeFunc) { } else { size *= 2 } - if size > max { - size = max + if size > maxSize { + size = maxSize } } } diff --git a/rbd/mirror.go b/rbd/mirror.go index bd85536b0e..ce279506c0 100644 --- a/rbd/mirror.go +++ b/rbd/mirror.go @@ -666,23 +666,23 @@ var iterBufSize = 64 // const char *start_id, size_t max, char **image_ids, // rbd_mirror_image_status_t *images, size_t *len) func MirrorImageGlobalStatusList( - ioctx *rados.IOContext, start string, max int) ([]GlobalMirrorImageIDAndStatus, error) { + ioctx *rados.IOContext, start string, maxItems int) ([]GlobalMirrorImageIDAndStatus, error) { var ( result []GlobalMirrorImageIDAndStatus fetchAll bool ) - if max <= 0 { - max = iterBufSize + if maxItems <= 0 { + maxItems = iterBufSize fetchAll = true } - chunk := make([]GlobalMirrorImageIDAndStatus, max) + chunk := make([]GlobalMirrorImageIDAndStatus, maxItems) for { length, err := mirrorImageGlobalStatusList(ioctx, start, chunk) if err != nil { return nil, err } result = append(result, chunk[:length]...) - if !fetchAll || length < max { + if !fetchAll || length < maxItems { break } start = chunk[length-1].ID @@ -700,15 +700,15 @@ func mirrorImageGlobalStatusList( defer C.free(unsafe.Pointer(cStart)) var ( - max = C.size_t(len(results)) - length = C.size_t(0) - ids = make([]*C.char, len(results)) - images = make([]C.rbd_mirror_image_global_status_t, len(results)) + maxItems = C.size_t(len(results)) + length = C.size_t(0) + ids = make([]*C.char, len(results)) + images = make([]C.rbd_mirror_image_global_status_t, len(results)) ) ret := C.rbd_mirror_image_global_status_list( cephIoctx(ioctx), cStart, - max, + maxItems, &ids[0], &images[0], &length) @@ -807,23 +807,23 @@ type MirrorImageInfoItem struct { // rbd_mirror_image_info_t *info_entries, size_t *num_entries) func MirrorImageInfoList( ioctx *rados.IOContext, modeFilter ImageMirrorModeFilter, start string, - max int) ([]MirrorImageInfoItem, error) { + maxItems int) ([]MirrorImageInfoItem, error) { var ( result []MirrorImageInfoItem fetchAll bool ) - if max <= 0 { - max = iterBufSize + if maxItems <= 0 { + maxItems = iterBufSize fetchAll = true } - chunk := make([]MirrorImageInfoItem, max) + chunk := make([]MirrorImageInfoItem, maxItems) for { length, err := mirrorImageInfoList(ioctx, start, modeFilter, chunk) if err != nil { return nil, err } result = append(result, chunk[:length]...) - if !fetchAll || length < max { + if !fetchAll || length < maxItems { break } start = chunk[length-1].ID @@ -838,7 +838,7 @@ func mirrorImageInfoList(ioctx *rados.IOContext, start string, defer C.free(unsafe.Pointer(cStart)) var ( - max = C.size_t(len(results)) + maxItems = C.size_t(len(results)) length = C.size_t(0) ids = make([]*C.char, len(results)) modes = make([]C.rbd_mirror_image_mode_t, len(results)) @@ -853,7 +853,7 @@ func mirrorImageInfoList(ioctx *rados.IOContext, start string, cephIoctx(ioctx), modeFilterPtr, cStart, - max, + maxItems, &ids[0], &modes[0], &infos[0], @@ -949,23 +949,23 @@ type MirrorImageInstanceIDItem struct { // size_t *len) func MirrorImageInstanceIDList( ioctx *rados.IOContext, start string, - max int) ([]MirrorImageInstanceIDItem, error) { + maxItems int) ([]MirrorImageInstanceIDItem, error) { var ( result []MirrorImageInstanceIDItem fetchAll bool ) - if max <= 0 { - max = iterBufSize + if maxItems <= 0 { + maxItems = iterBufSize fetchAll = true } - chunk := make([]MirrorImageInstanceIDItem, max) + chunk := make([]MirrorImageInstanceIDItem, maxItems) for { length, err := mirrorImageInstanceIDList(ioctx, start, chunk) if err != nil { return nil, err } result = append(result, chunk[:length]...) - if !fetchAll || length < max { + if !fetchAll || length < maxItems { break } start = chunk[length-1].ID @@ -980,7 +980,7 @@ func mirrorImageInstanceIDList(ioctx *rados.IOContext, start string, defer C.free(unsafe.Pointer(cStart)) var ( - max = C.size_t(len(results)) + maxItems = C.size_t(len(results)) length = C.size_t(0) ids = make([]*C.char, len(results)) instanceIDs = make([]*C.char, len(results)) @@ -988,7 +988,7 @@ func mirrorImageInstanceIDList(ioctx *rados.IOContext, start string, ret := C.rbd_mirror_image_instance_id_list( cephIoctx(ioctx), cStart, - max, + maxItems, &ids[0], &instanceIDs[0], &length,