Skip to content

Update for Swift 5.2 needed #314

@mman

Description

@mman

The code compiled under Linux 5.2 produces the warnings below. All related to the new semantics of handling unsafe pointers. Will you accept a PR if I provide one?

/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/BufferList.swift:155:29: warning: initialization of 'UnsafeMutablePointer<UInt8>' results in a dangling pointer
        return fill(buffer: UnsafeMutablePointer(mutating: array), length: array.count)
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/BufferList.swift:155:60: note: implicit argument conversion from '[UInt8]' to 'UnsafePointer<UInt8>' produces a pointer valid only for the duration of the call to 'init(mutating:)'
        return fill(buffer: UnsafeMutablePointer(mutating: array), length: array.count)
                                                           ^~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/BufferList.swift:155:60: note: use the 'withUnsafeBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
        return fill(buffer: UnsafeMutablePointer(mutating: array), length: array.count)
                                                           ^
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:593:59: warning: initialization of 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>') results in a dangling pointer
        curlHelperSetOptString(self.handle!, CURLOPT_URL, UnsafePointer(urlBuffer))
                                                          ^~~~~~~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:593:73: note: implicit argument conversion from '[CChar]' (aka 'Array<Int8>') to 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>') produces a pointer valid only for the duration of the call to 'init(_:)'
        curlHelperSetOptString(self.handle!, CURLOPT_URL, UnsafePointer(urlBuffer))
                                                                        ^~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:593:73: note: use the 'withUnsafeBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
        curlHelperSetOptString(self.handle!, CURLOPT_URL, UnsafePointer(urlBuffer))
                                                                        ^
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:610:50: warning: initialization of 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>') results in a dangling pointer
            curlHelperSetUnixSocketPath(handle!, UnsafePointer(socketPath))
                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:610:64: note: implicit argument conversion from '[CChar]' (aka 'Array<Int8>') to 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>') produces a pointer valid only for the duration of the call to 'init(_:)'
            curlHelperSetUnixSocketPath(handle!, UnsafePointer(socketPath))
                                                               ^~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:610:64: note: use the 'withUnsafeBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
            curlHelperSetUnixSocketPath(handle!, UnsafePointer(socketPath))
                                                               ^
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:653:62: warning: initialization of 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>') results in a dangling pointer
                headersList = curl_slist_append(headersList, UnsafePointer(headerString))
                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:653:76: note: implicit argument conversion from '[CChar]' (aka 'Array<Int8>') to 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>') produces a pointer valid only for the duration of the call to 'init(_:)'
                headersList = curl_slist_append(headersList, UnsafePointer(headerString))
                                                                           ^~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/ClientRequest.swift:653:76: note: use the 'withUnsafeBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
                headersList = curl_slist_append(headersList, UnsafePointer(headerString))
                                                                           ^
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/FastCGI/FastCGIRecordParser.swift:91:36: warning: initialization of 'UnsafeRawPointer' results in a dangling pointer
        let networkOrderedUInt16 = UnsafeRawPointer(networkOrderedBytes).assumingMemoryBound(to: UInt16.self)[0]
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/FastCGI/FastCGIRecordParser.swift:91:53: note: implicit argument conversion from '[UInt8]' to 'UnsafeRawPointer' produces a pointer valid only for the duration of the call to 'init(_:)'
        let networkOrderedUInt16 = UnsafeRawPointer(networkOrderedBytes).assumingMemoryBound(to: UInt16.self)[0]
                                                    ^~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/FastCGI/FastCGIRecordParser.swift:91:53: note: use the 'withUnsafeBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
        let networkOrderedUInt16 = UnsafeRawPointer(networkOrderedBytes).assumingMemoryBound(to: UInt16.self)[0]
                                                    ^
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/FastCGI/FastCGIRecordParser.swift:105:36: warning: initialization of 'UnsafeRawPointer' results in a dangling pointer
        let networkOrderedUInt32 = UnsafeRawPointer(networkOrderedBytes).assumingMemoryBound(to: UInt32.self)[0]
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/FastCGI/FastCGIRecordParser.swift:105:53: note: implicit argument conversion from '[UInt8]' to 'UnsafeRawPointer' produces a pointer valid only for the duration of the call to 'init(_:)'
        let networkOrderedUInt32 = UnsafeRawPointer(networkOrderedBytes).assumingMemoryBound(to: UInt32.self)[0]
                                                    ^~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/FastCGI/FastCGIRecordParser.swift:105:53: note: use the 'withUnsafeBytes' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
        let networkOrderedUInt32 = UnsafeRawPointer(networkOrderedBytes).assumingMemoryBound(to: UInt32.self)[0]
                                                    ^
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/HTTP/HTTPServerResponse.swift:267:27: warning: initialization of 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>') results in a dangling pointer
            buffer.append(UnsafePointer(utf8), length: utf8Length)
                          ^~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/HTTP/HTTPServerResponse.swift:267:41: note: implicit argument conversion from '[CChar]' (aka 'Array<Int8>') to 'UnsafePointer<CChar>' (aka 'UnsafePointer<Int8>') produces a pointer valid only for the duration of the call to 'init(_:)'
            buffer.append(UnsafePointer(utf8), length: utf8Length)
                                        ^~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/HTTP/HTTPServerResponse.swift:267:41: note: use the 'withUnsafeBufferPointer' method on Array in order to explicitly convert argument to buffer pointer valid for a defined scope
            buffer.append(UnsafePointer(utf8), length: utf8Length)
                                        ^
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/HTTPParser/HTTPParser.swift:82:23: warning: initialization of 'UnsafeMutableRawPointer' results in a dangling pointer
        parser.data = UnsafeMutableRawPointer(&parseResults)
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/HTTPParser/HTTPParser.swift:82:47: note: implicit argument conversion from 'ParseResults' to 'UnsafeMutableRawPointer' produces a pointer valid only for the duration of the call to 'init(_:)'
        parser.data = UnsafeMutableRawPointer(&parseResults)
                                              ^~~~~~~~~~~~~
/root/exampleapp/.build/checkouts/Kitura-net/Sources/KituraNet/HTTPParser/HTTPParser.swift:82:47: note: use 'withUnsafeMutableBytes' in order to explicitly convert argument to buffer pointer valid for a defined scope
        parser.data = UnsafeMutableRawPointer(&parseResults)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions