Skip to contentSkip to conversation

question on type conversions in show_map_vma()

DISCUSSION Chris Friesen 1 participant 1 message Dec 2, 2009

lore
Share & tools
lore
#0 lore raw

Another developer and I were looking at show_map_vma() and started wondering about the "pgoff" value:

pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;

Here we take a variable of type "unsigned long", we cast it to "long long", shift it, then assign the result to a variable of type "unsigned long long".

I realize that there isn't any danger of invalid sign extension, but it does seem a bit odd to be casting to a signed value when the result is going to be unsigned.

Is there a historical reason why pgoff is unsigned rather than just of type "loff_t"?

Chris