diff options
author | Kevin Newton <[email protected]> | 2024-04-16 21:15:12 -0400 |
---|---|---|
committer | git <[email protected]> | 2024-04-17 01:15:21 +0000 |
commit | f34409bf8782481deabec6c577abd66373134af9 (patch) | |
tree | 4e63c3eb9864d290103c5eb2f4ceeb7ec14ffa13 /prism/options.c | |
parent | d6debba817da921d8bc9a3fdb6b4bcbe3d7b0859 (diff) |
[ruby/prism] Fix up more clang-analyzer failures
https://github.com/ruby/prism/commit/f9a1abbc64
Diffstat (limited to 'prism/options.c')
-rw-r--r-- | prism/options.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/prism/options.c b/prism/options.c index 2854b765b9..4d0d6dbc49 100644 --- a/prism/options.c +++ b/prism/options.c @@ -47,29 +47,40 @@ pm_options_command_line_set(pm_options_t *options, uint8_t command_line) { */ PRISM_EXPORTED_FUNCTION bool pm_options_version_set(pm_options_t *options, const char *version, size_t length) { - if (version == NULL && length == 0) { - options->version = PM_OPTIONS_VERSION_LATEST; - return true; - } + switch (length) { + case 0: + if (version == NULL) { + options->version = PM_OPTIONS_VERSION_LATEST; + return true; + } - if (length == 5) { - if (strncmp(version, "3.3.0", length) == 0) { - options->version = PM_OPTIONS_VERSION_CRUBY_3_3_0; - return true; - } + return false; + case 5: + assert(version != NULL); - if (strncmp(version, "3.4.0", length) == 0) { - options->version = PM_OPTIONS_VERSION_LATEST; - return true; - } - } + if (strncmp(version, "3.3.0", length) == 0) { + options->version = PM_OPTIONS_VERSION_CRUBY_3_3_0; + return true; + } - if (length == 6 && strncmp(version, "latest", length) == 0) { - options->version = PM_OPTIONS_VERSION_LATEST; - return true; - } + if (strncmp(version, "3.4.0", length) == 0) { + options->version = PM_OPTIONS_VERSION_LATEST; + return true; + } + + return false; + case 6: + assert(version != NULL); - return false; + if (strncmp(version, "latest", length) == 0) { + options->version = PM_OPTIONS_VERSION_LATEST; + return true; + } + + return false; + default: + return false; + } } // For some reason, GCC analyzer thinks we're leaking allocated scopes and |