Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: fix warnings found by nightly compiler #5582

Closed
wants to merge 1 commit into from

Conversation

catenacyber
Copy link
Contributor

Link to redmine ticket:
None

Describe changes:

  • Fixes a warning found by rust nightly compiler

My compiler is rustc 1.50.0-nightly (603ab5bd6 2020-11-15)

The full warning text is

warning: getting the inner pointer of a temporary `CString`
  --> src/conf.rs:38:47
   |
38 |         if ConfGet(CString::new(key).unwrap().as_ptr(), &mut vptr) != 1 {
   |                    -------------------------- ^^^^^^ 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: getting the inner pointer of a temporary `CString`
this `CString` is deallocated at the end of the statement,
bind it to a variable to extend its lifetime
Copy link
Member

@jasonish jasonish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, Important to get this in I think. We might want to backport it as well.

I'm surprised, in other cases with a temporary value, Rustc plain just fails out.

@catenacyber
Copy link
Contributor Author

@victorjulien
Copy link
Member

Merged in #5600, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants