OSDN Git Service

Silence a warning.
authorRob Landley <rob@landley.net>
Sun, 5 Feb 2017 06:51:18 +0000 (00:51 -0600)
committerRob Landley <rob@landley.net>
Sun, 5 Feb 2017 06:51:18 +0000 (00:51 -0600)
commit4a4b3d65644ce403b0f22887fc0d38b0202ec8c7
tree2baba9ef32aebd7cd40d3a63951eaba250233f09
parent796d873d95e1be63ece2345d0e985a057210c1b9
Silence a warning.

Once upon a time you could call fchown() and let it fail. Then gcc decided
not using its return code was inconcievable, but you could typecast it to (void)
to shut it up. Then gcc noticed people doing that and clutched its pearls and
took it away, so I added an if() statement that does nothing with the result
because we _expect_ this to fail when we're not root. Then clang started
complaining about an if (); statement with the semicolon on the same line,
but decided it's ok if the ; is on the next line (I.E. significant whitespace
in C), so I'm adding an "assignemnt to self" that gets optimized away so
it does a more _explicit_ nothing (the same way you suppress gcc's broken
"this isn't used uninitialized" warnings).

If the compilers weren't going to so much trouble to force the issue I might
add code to only call fchown when we're UID 0, but I refuse to be coerced
into it. (And if getpid() is still a system call instead of a vdso member
then it doesn't actually _save_ us anything, the dentry should be hot and
the permission check was just "if (!uid)" before selinux entered into it and
we're operating on an fd so the security's the same.)
lib/lib.c