Skip to content

fuse: replace deprecated StringBytePtr with BytePtrFromString#531

Closed
Stavrospanakakis wants to merge 1 commit intohanwen:masterfrom
Stavrospanakakis:fix/deprecated-StringBytePtr
Closed

fuse: replace deprecated StringBytePtr with BytePtrFromString#531
Stavrospanakakis wants to merge 1 commit intohanwen:masterfrom
Stavrospanakakis:fix/deprecated-StringBytePtr

Conversation

@Stavrospanakakis
Copy link
Contributor

As mentioned in the Go codebase, the method syscall.StringBytePtr is deprecated and has to be replaced with syscall.BytePtrFromString.

// StringBytePtr returns a pointer to a NUL-terminated array of bytes.
// If s contains a NUL byte this function panics instead of returning
// an error.
//
// Deprecated: Use [BytePtrFromString] instead.
func StringBytePtr(s string) *byte { return &StringByteSlice(s)[0] }

// BytePtrFromString returns a pointer to a NUL-terminated array of
// bytes containing the text of s. If s contains a NUL byte at any
// location, it returns (nil, [EINVAL]).
func BytePtrFromString(s string) (*byte, error) {
	a, err := ByteSliceFromString(s)
	if err != nil {
		return nil, err
	}
	return &a[0], nil
}

https://github.com/golang/go/blob/8a4b439ee6e0f5d41cb6ae30146b901f3c0ad4b7/src/syscall/syscall.go#L57-L73

This pull request replaces the deprecated method.

Change-Id: I31b52356438352829971c6b491d37fe09e088911

Change-Id: I31b52356438352829971c6b491d37fe09e088911
@hanwen
Copy link
Owner

hanwen commented Sep 14, 2024

can you upload to gerrithub? thanks. See CONTRIBUTING.

@Stavrospanakakis
Copy link
Contributor Author

@hanwen Sure, I uploaded the code to gerrithub.
https://review.gerrithub.io/c/hanwen/go-fuse/+/1201253

@hanwen
Copy link
Owner

hanwen commented Sep 15, 2024

thanks! merged as 58e0d83

@hanwen hanwen closed this Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants