Closed petterreinholdtsen closed 8 years ago
The &gids[0]
construct is unnecessary since, by definition, an array identifier evaluates to a pointer to the array's first member.
BTW, 32 was chosen as the largest number which we can reasonably assume is less than or equal to NGROUPS_MAX
. Ten years ago, that number would have been 16.
[Dag-Erling Smørgrav]
The
&gids[0]
construct is unnecessary since, by definition, an array identifier evaluates to a pointer to the array's first member.
I know it do not tell the compiler anything interesting, but I believe it make it easier for humans to infer that the gids variable is an array, and use the construct for the extra information it convey to the reader.
Happy hacking Petter Reinholdtsen
[Dag-Erling Smørgrav]
BTW, 32 was chosen as the largest number which we can reasonably assume is less than or equal to
NGROUPS_MAX
. Ten years ago, that number would have been 16.
Given that NFS still can't handle more than 16 groups, I am not sure which value make more sense to us. :)
Happy hacking Petter Reinholdtsen
I don't see what extra information it conveys. The reader does not need to know, at that point, whether gids
is an array or a pointer to an array.
[Dag-Erling Smørgrav]
I don't see what extra information it conveys. The reader does not need to know, at that point, whether
gids
is an array or a pointer to an array.
Using the &gids[0] notation make it obvious for the reader that the gids variable isn't an float or integer type or a void pointer, and if one never use that notation for pointers but only for arrays, it become obvious that gids is an array and not a pointer. &gids would work for any type, while &gids[0] only work for arrays and pointers. It is one of the defensive coding techniques I try to follow.
Happy hacking Petter Reinholdtsen
I'm not asking you to change it, but I honestly don't understand what good it's supposed to do. If anything, I'd say it misleads the reader into thinking that you're passing a pointer to a single element rather than to the entire array, which would, logically, be &gids
. You wouldn't use that notation if gids
was an actual pointer, even though the result would be exactly the same. I think it sticks out like a sore thumb and causes the reader to pause and wonder if it means something more than it appears to and to waste time trying to figure out what that would be.
Earlier, the scanner process would only be running as the toplevel directory owner user, and with the primary group set to the toplevel directory group. This would block access if the user need group membership in several groups to get access to the toplevel directory.
Change the code to look up and use the users group membership also when scanning.