I have some problem on function sdsrange(). https://github.com/antirez/redis/blob/843de8b786562d8d77c78d83a971060adc61f77a/src/sds.c#L735-L761

1. Does start=0 at line 756 necessary?

If newlen==0 is true, value of start is irrelevant, mommove will not execute. All lint tools can pass after deleting start=0;

2. If start=0 is necessary, why not it be codes below?

if (newlen != 0) {
    // ... may be newlen=0;
}
if (newlen == 0) {
    start = 0;
}

newlen may be changed to 0 in if clause, so it is possible that newlen=0 and start=0 be not set. So I think start=0 should not be in else clause if start=0 is really meaningful.

3. Why sdsrange() allow program keep running and notice nothing when something when wrong?

The "something when wrong" things will not happen to this program though.

Comment From: trevor211

Already optimized in f15df8ba5d. Safe to close. @oranagra

Comment From: oranagra

I find it hard to believe that an issue from 2019 was solved by a commit i made in 2015 8-)

but yes, it was recently solved in https://github.com/redis/redis/pull/7620

@zltl i don't understand your 3rd bullet. i suppose it's not relevant since your first claim (that start=0 is unnecessary). but if it is, please respond or open a new issue (or PR). Meanwhile, i'm closing this issue.