Commit 87d2d4b
committed
fix: address integer conversion issues and impossible uint64 comparisons
Fixed multiple issues identified by golangci-lint and CodeQL:
1. Removed impossible uint64 comparisons (SA4003):
- Removed check for blockNum < 0 in tview_renderer.go since blockNum is uint64
- Removed check for result > math.MaxUint64 in rpctypes.go since result is already uint64
2. Fixed unsafe uint64 to int64 conversions in calculateBlockInterval:
- Keep timestamp calculations as uint64 to avoid overflow
- Check that blockTime >= parentTime before subtraction
- Calculate interval and average interval using uint64 arithmetic
- Removed unnecessary bounds checks for MaxInt641 parent 1c79b7e commit 87d2d4b
1 file changed
+17
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2037 | 2037 | | |
2038 | 2038 | | |
2039 | 2039 | | |
2040 | | - | |
2041 | | - | |
2042 | | - | |
2043 | | - | |
2044 | | - | |
2045 | | - | |
2046 | | - | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
2047 | 2044 | | |
2048 | 2045 | | |
2049 | | - | |
2050 | | - | |
2051 | | - | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
2052 | 2052 | | |
2053 | 2053 | | |
2054 | 2054 | | |
| |||
2065 | 2065 | | |
2066 | 2066 | | |
2067 | 2067 | | |
2068 | | - | |
2069 | | - | |
2070 | | - | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
2071 | 2071 | | |
2072 | 2072 | | |
2073 | | - | |
| 2073 | + | |
2074 | 2074 | | |
2075 | 2075 | | |
2076 | 2076 | | |
2077 | | - | |
2078 | | - | |
| 2077 | + | |
| 2078 | + | |
2079 | 2079 | | |
2080 | 2080 | | |
2081 | 2081 | | |
2082 | 2082 | | |
2083 | | - | |
2084 | | - | |
2085 | | - | |
2086 | | - | |
2087 | | - | |
2088 | | - | |
| 2083 | + | |
2089 | 2084 | | |
2090 | 2085 | | |
2091 | 2086 | | |
| |||
0 commit comments