]> Kevux Git Server - fll/commitdiff
Cleanup: Use signed type and cast to unsigned.
authorKevin Day <thekevinday@gmail.com>
Sat, 19 Feb 2022 04:59:24 +0000 (22:59 -0600)
committerKevin Day <thekevinday@gmail.com>
Sat, 19 Feb 2022 04:59:24 +0000 (22:59 -0600)
This situation is exposed by a warning from the CLang compiler.
The warning makes sense, so the code is changed to a signed type and then cast.

The negative value should never make it to the assignment if the preceding if condition properly catches it as intended.

level_3/controller/c/rule/private-rule.c

index e7e52dba7a5306234ac585d7a03b085bb147fe71..03cb8e13b3d7b7e6540652d53058075aa9db2dc2 100644 (file)
@@ -685,7 +685,7 @@ extern "C" {
   f_status_t controller_rule_action_read_rerun_number(const controller_global_t global, const f_string_t name, controller_cache_t * const cache, f_array_length_t * const index, f_number_unsigned_t * const number) {
 
     f_status_t status = F_none;
-    f_number_unsigned_t parsed = 0;
+    f_number_signed_t parsed = 0;
 
     if (*index + 1 == cache->content_action.used) {
       status = F_status_set_error(F_valid_not);
@@ -744,7 +744,7 @@ extern "C" {
       return status;
     }
 
-    *number = parsed;
+    *number = (f_number_unsigned_t) parsed;
 
     return F_none;
   }