all: not add or subtract one when compare integers

This commit is contained in:
Daniel Liu 2025-04-25 10:41:33 +08:00
parent b62756d1a3
commit dd18516601
3 changed files with 3 additions and 3 deletions

View file

@ -151,7 +151,7 @@ func parseFilters(args []string) ([]nodeFilter, error) {
if !ok { if !ok {
return nil, fmt.Errorf("invalid filter %q", args[0]) return nil, fmt.Errorf("invalid filter %q", args[0])
} }
if len(args)-1 < fc.narg { if len(args) <= fc.narg {
return nil, fmt.Errorf("filter %q wants %d arguments, have %d", args[0], fc.narg, len(args)-1) return nil, fmt.Errorf("filter %q wants %d arguments, have %d", args[0], fc.narg, len(args)-1)
} }
filter, err := fc.fn(args[1 : 1+fc.narg]) filter, err := fc.fn(args[1 : 1+fc.narg])

View file

@ -195,7 +195,7 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
first = frozen // the first block to freeze first = frozen // the first block to freeze
last = threshold // the last block to freeze last = threshold // the last block to freeze
) )
if last-first+1 > freezerBatchLimit { if last-first >= freezerBatchLimit {
last = freezerBatchLimit + first - 1 last = freezerBatchLimit + first - 1
} }
ancients, err := f.freezeRange(nfdb, first, last) ancients, err := f.freezeRange(nfdb, first, last)

View file

@ -40,7 +40,7 @@ const (
// ipcListen will create a Unix socket on the given endpoint. // ipcListen will create a Unix socket on the given endpoint.
func ipcListen(endpoint string) (net.Listener, error) { func ipcListen(endpoint string) (net.Listener, error) {
// account for null-terminator too // account for null-terminator too
if len(endpoint)+1 > maxPathSize { if len(endpoint) >= maxPathSize {
log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", maxPathSize-1), log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", maxPathSize-1),
"endpoint", endpoint) "endpoint", endpoint)
} }