mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
rbd: export HexStringToInteger()
HexStringToInteger() used to return a uint64, but everywhere else uint is used. Having HexStringToInteger() return a uint as well makes it a little easier to use when setting it with SetGlobalInt(). Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
8b531f337e
commit
44d69502bc
@ -250,8 +250,8 @@ func GetKrbdSupportedFeatures() (string, error) {
|
||||
return strings.TrimSuffix(string(val), "\n"), nil
|
||||
}
|
||||
|
||||
// hexStringToInteger convert hex value to uint.
|
||||
func hexStringToInteger(hexString string) (uint64, error) {
|
||||
// HexStringToInteger convert hex value to uint.
|
||||
func HexStringToInteger(hexString string) (uint, error) {
|
||||
// trim 0x prefix
|
||||
numberStr := strings.TrimPrefix(strings.ToLower(hexString), "0x")
|
||||
|
||||
@ -262,7 +262,7 @@ func hexStringToInteger(hexString string) (uint64, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return output, nil
|
||||
return uint(output), nil
|
||||
}
|
||||
|
||||
// isKrbdFeatureSupported checks if a given Image Feature is supported by krbd
|
||||
@ -274,7 +274,7 @@ func isKrbdFeatureSupported(ctx context.Context, imageFeatures string) bool {
|
||||
|
||||
supported := true
|
||||
for _, featureName := range imageFeatureSet.Names() {
|
||||
if (uint64(librbd.FeatureSetFromNames(strings.Split(featureName, " "))) & krbdFeatures) == 0 {
|
||||
if (uint(librbd.FeatureSetFromNames(strings.Split(featureName, " "))) & krbdFeatures) == 0 {
|
||||
supported = false
|
||||
log.ErrorLog(ctx, "krbd feature %q not supported", featureName)
|
||||
|
||||
|
@ -334,9 +334,9 @@ func TestIsKrbdFeatureSupported(t *testing.T) {
|
||||
t.Parallel()
|
||||
var err error
|
||||
krbdSupportedFeaturesAttr := "0x1"
|
||||
krbdFeatures, err = hexStringToInteger(krbdSupportedFeaturesAttr) // initialize krbdFeatures
|
||||
krbdFeatures, err = HexStringToInteger(krbdSupportedFeaturesAttr) // initialize krbdFeatures
|
||||
if err != nil {
|
||||
t.Errorf("hexStringToInteger(%s) failed", krbdSupportedFeaturesAttr)
|
||||
t.Errorf("HexStringToInteger(%s) failed", krbdSupportedFeaturesAttr)
|
||||
}
|
||||
supported := isKrbdFeatureSupported(ctx, tc.featureName)
|
||||
if supported != tc.isSupported {
|
||||
|
Loading…
Reference in New Issue
Block a user