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

Fix getting settings default result #3103

Merged
merged 2 commits into from
Apr 26, 2023

Conversation

magicrub
Copy link
Contributor

This adds a new GetDecimal() helper but also it ensures the default value is returned when a TryParse() fails in the various helpers.

Current code assumes TryParse(string, result)==false does not touch result because we are initially setting the result with the default value and then always return the value without checking the return boolean. However, the docs say it will trample on result when returning false. Here's the docs for Int32.TryParse()

       //   result:
        //     When this method returns, contains the 32-bit signed integer value equivalent
        //     of the number contained in s, if the conversion succeeded, or zero if the conversion
        //     failed. The conversion fails if the s parameter is null or System.String.Empty,
        //     is not of the correct format, or represents a number less than System.Int32.MinValue
        //     or greater than System.Int32.MaxValue. This parameter is passed uninitialized;
        //     any value originally supplied in result will be overwritten.
        //
        //  public static bool TryParse(string s, out Int32 result);

@meee1 meee1 merged commit 3ed753c into ArduPilot:master Apr 26, 2023
@magicrub magicrub deleted the pr/settings_default branch April 26, 2023 23:55
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