Closed AreaZR closed 1 year ago
The use of int here is intentional. The problem with printing uid/gid as unsigned is that it ends up printing -1 as a large unsigned value which is not very useful. In system calls, a -1 value is used to indicate "no change" and it is helpful to preserve that in the debug output.
It gets printed as -1, I made sure of that, but yeah I can see why this would be a problem.
Printing (unsigned int)-1 with the %u printf format will display 4294967295
, not -1
.
gid and uid are unsigned on most platforms, and mode_t, being unsigned short but also passed as an int to some functions, are best passed cast to an integer.