lluiscab / MPQTT

MPQTT is a linux program used to extract data from Voltronic / Axpert / MasterPower inverters and sending it to MQTT for use in Home Assistant
10 stars 4 forks source link

Build error message #3

Closed Saentist closed 2 years ago

Saentist commented 2 years ago

building under Ubuntu 20.04.4 LTS kernel 5.13.0-48-generic

warning: getting the inner pointer of a temporary `CString`
   --> src/main.rs:185:88
    |
185 |     let fd = unsafe { open(CString::new(path.as_ref().as_os_str().as_bytes()).unwrap().as_ptr(), O_RDWR) };
    |                            ----------------------------------------------------------- ^^^^^^ this pointer will be invalid
    |                            |
    |                            this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime
    |
    = note: `#[warn(temporary_cstring_as_ptr)]` on by default
    = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned
    = help: for more information, see https://doc.rust-lang.org/reference/destructors.html

warning: `mpqtt` (bin "mpqtt") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 33m 33s

is there a problem or can be skiped?

lluiscab commented 2 years ago

What you are seeing is a warning and so it can be ignored.

azteca1998 commented 2 years ago

This issue is undefined behavior in disguise, and under a normal Rust context (not unsafe FFI) would cause a compilation error (E0716).

azteca1998 commented 2 years ago

Should be fixed now..

Saentist commented 2 years ago
cargo b
   Compiling libc v0.2.126
   Compiling memchr v2.5.0
   Compiling proc-macro2 v1.0.39
   Compiling unicode-ident v1.0.1
   Compiling log v0.4.17
   Compiling cfg-if v1.0.0
   Compiling syn v1.0.96
   Compiling futures-core v0.3.21
   Compiling cfg-if v0.1.10
   Compiling cc v1.0.73
   Compiling slab v0.4.6
   Compiling byteorder v1.4.3
   Compiling serde v1.0.137
   Compiling untrusted v0.7.1
   Compiling spin v0.5.2
   Compiling lazy_static v1.4.0
   Compiling autocfg v1.1.0
   Compiling once_cell v1.12.0
   Compiling bytes v0.5.6
   Compiling regex-syntax v0.6.26
   Compiling futures-sink v0.3.21
   Compiling fnv v1.0.7
   Compiling pin-project-lite v0.1.12
   Compiling futures-channel v0.3.21
   Compiling serde v0.8.23
   Compiling version_check v0.1.5
   Compiling futures-task v0.3.21
   Compiling serde_json v1.0.81
   Compiling quick-error v1.2.3
   Compiling futures-util v0.3.21
   Compiling serde_derive v1.0.137
   Compiling linked-hash-map v0.5.4
   Compiling futures-io v0.3.21
   Compiling ryu v1.0.10
   Compiling pin-project-lite v0.2.9
   Compiling itoa v1.0.2
   Compiling pin-utils v0.1.0
   Compiling debug-helper v0.3.13
   Compiling termcolor v1.1.3
   Compiling lazy_static v0.2.11
   Compiling rust-ini v0.13.0
   Compiling maplit v1.0.2
   Compiling base64 v0.10.1
   Compiling num-traits v0.2.15
   Compiling ring v0.16.20
   Compiling serde_test v0.8.23
   Compiling nom v4.2.3
   Compiling humantime v1.3.0
   Compiling yaml-rust v0.4.5
   Compiling crc-any v2.4.3
   Compiling linked-hash-map v0.3.0
   Compiling aho-corasick v0.7.18
   Compiling iovec v0.1.4
   Compiling net2 v0.2.37
   Compiling num_cpus v1.13.1
   Compiling signal-hook-registry v1.4.0
   Compiling atty v0.2.14
   Compiling quote v1.0.18
   Compiling regex v1.5.6
   Compiling bytes v0.4.12
   Compiling toml v0.4.10
   Compiling mio v0.6.23
   Compiling num-traits v0.1.43
   Compiling env_logger v0.7.1
   Compiling sct v0.6.1
   Compiling webpki v0.21.4
   Compiling mqttrs v0.2.0
   Compiling mio-uds v0.6.8
   Compiling serde-hjson v0.8.2
   Compiling pretty_env_logger v0.4.0
   Compiling rustls v0.16.0
   Compiling config v0.9.3
   Compiling tokio-macros v0.2.6
   Compiling futures-macro v0.3.21
   Compiling tokio v0.2.25
   Compiling tokio-util v0.3.1
   Compiling tokio-rustls v0.12.3
   Compiling masterpower-api v0.1.0 (https://github.com/azteca1998/masterpower-api?branch=dev#f7203fc9)
   Compiling mqtt-async-client v0.1.7
   Compiling mpqtt v1.1.0 (/opt/MPQTT)
    Finished dev [unoptimized + debuginfo] target(s) in 21m 30s

Build pass without any extra messages.