Skip to content

Commit

Permalink
build: depend on go1.21
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nixpanic committed Jan 9, 2025
1 parent 70fd8f1 commit 26731e2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions internal/retry/sizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ 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 {
size = hint.size()
} else {
size *= 2
}
if size > max {
size = max
if size > maxSize {
size = maxSize
}
}
}
48 changes: 24 additions & 24 deletions rbd/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -853,7 +853,7 @@ func mirrorImageInfoList(ioctx *rados.IOContext, start string,
cephIoctx(ioctx),
modeFilterPtr,
cStart,
max,
maxItems,
&ids[0],
&modes[0],
&infos[0],
Expand Down Expand Up @@ -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
Expand All @@ -980,15 +980,15 @@ 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))
)
ret := C.rbd_mirror_image_instance_id_list(
cephIoctx(ioctx),
cStart,
max,
maxItems,
&ids[0],
&instanceIDs[0],
&length,
Expand Down

0 comments on commit 26731e2

Please sign in to comment.