Use the same-type variable in a loop, as in loop condition

This fixes (most of the) warnings like this:
darktable/src/common/cache.c:382:17: warning: comparison of integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') [-Wsign-compare]
  for(int k=0; k<=cache->segment_mask; k++)
               ~^ ~~~~~~~~~~~~~~~~~~~