in src/t_zset.c flie, the maintance of span in a loop, why the condition cannot be ' while(zsl->level >= 1 && zsl->header->level[zsl->level-1].forward == NULL) '.

Comment From: oranagra

@Ysoretarted please be more specific. please state the function or line you're referring to. What is the current code and why what you suggest is better or how is it different.

Comment From: Ysoretarted

@oranagra sorry ... on 6.0 branch, in src/t_zset.c 。 On the 206th line, why the judge condition connot be zsl->level >= 1

so, zsl.level can reduce to 0 when deleting all the node in the list.

Comment From: oranagra

@Ysoretarted it's really hard to understand what you mean.

i suppose you're referring to zslDeleteNode: https://github.com/redis/redis/blob/36b949438547eb5bf8555fcac2c5040528fd7854/src/t_zset.c#L206

and you're suggesting:

-    while(zsl->level > 1 && zsl->header->level[zsl->level-1].forward == NULL)
+    while(zsl->level >= 1 && zsl->header->level[zsl->level-1].forward == NULL)
        zsl->level--;

i.e. to change zsl->level > 1 to zsl->level >= 1 from what i can tell that would lead to: 1. access violation on that very first line, since we'll be accessing the header->level array at index -1. 2. assuming the access violation will not be detected, it would cause zsl->level to be -1.

Comment From: Ysoretarted

@oranagra Thank you sincerely!!