Commit b51f885
authored
[Fix] Resolve int32 overflow by having the calculation in int64 and c… (#4158)
* [Fix] Resolve int32 overflow by having the calculation in int64 and cap it if the count is over math.MaxInt32
Signed-off-by: justinyeh1995 <[email protected]>
* [Test] Add unit tests for CalculateReadyReplicas
Signed-off-by: justinyeh1995 <[email protected]>
* [Fix] Add a nosec comment to pass the Lint (pre-commit) test
Signed-off-by: justinyeh1995 <[email protected]>
* [Refactor] Add CapInt64ToInt32 to replace #nosec directives
Signed-off-by: justinyeh1995 <[email protected]>
* [Refactor] Rename function to SafeInt64ToInt32 and add a underflowing prevention (it also help pass the lint test)
Signed-off-by: justinyeh1995 <[email protected]>
* [Refactor] Remove the early return as SafeInt64ToInt32 handles the int32 overflow and underflow checking.
Signed-off-by: justinyeh1995 <[email protected]>
---------
Signed-off-by: justinyeh1995 <[email protected]>1 parent 470d651 commit b51f885
2 files changed
+109
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
256 | 268 | | |
257 | 269 | | |
258 | 270 | | |
| |||
393 | 405 | | |
394 | 406 | | |
395 | 407 | | |
396 | | - | |
| 408 | + | |
397 | 409 | | |
398 | 410 | | |
399 | 411 | | |
400 | 412 | | |
401 | | - | |
| 413 | + | |
402 | 414 | | |
403 | 415 | | |
404 | | - | |
| 416 | + | |
405 | 417 | | |
406 | 418 | | |
407 | 419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
805 | 805 | | |
806 | 806 | | |
807 | 807 | | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
808 | 902 | | |
809 | 903 | | |
810 | 904 | | |
| |||
0 commit comments