2009-12-02 18:36:49

by Chris Friesen

[permalink] [raw]
Subject: question on type conversions in show_map_vma()


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