philbot9/generic-linked-list

unsigned vs signed comparison in implementation

Closed this issue · 2 comments

netik commented

In gll.h, list->size is declared as unsigned int; In functions that manipulate the list position, these calls are signed int. This can cause issues with large lists and should be fixed.

Either make list->size signed int (which is how I fixed this in my copy of the code), or make all of the position code use unsigned int. Either way, they must be in agreement.

Nice catch, thank you for this. Another example of how old code never dies 😉.

Changing the position parameter to an unsigned int makes more sense to me since it should never be negative anyhow. Fixed in f5cd602.

On second thought, I'm going to go with signed int everywhere. I think otherwise existing client code should be updated to use unsigned int, which isn't great.