On 08/10/2012 07:48 AM, Daniel P. Berrange wrote: > From: "Daniel P. Berrange" <[email protected]> > > The code for picking a MCS label is about to get significantly > more complicated, so it deserves to be in a standlone method, > instead of a switch/case body. > > Signed-off-by: Daniel P. Berrange <[email protected]> > --- > src/security/security_selinux.c | 75 > ++++++++++++++++++++++++++--------------- > 1 file changed, 47 insertions(+), 28 deletions(-) >
ACK.
> +
> +static char *
> +virSecuritySELinuxMCSFind(virSecurityManagerPtr mgr)
> +{
> + virSecuritySELinuxDataPtr data = virSecurityManagerGetPrivateData(mgr);
> + int c1 = 0;
> + int c2 = 0;
> + char *mcs = NULL;
> +
> + for (;;) {
> + c1 = virRandomBits(10);
> + c2 = virRandomBits(10);
> +
> + if (c1 == c2) {
> + if (virAsprintf(&mcs, "s0:c%d", c1) < 0) {
> + virReportOOMError();
> + return NULL;
> + }
> + } else {
> + if (c1 > c2) {
> + c1 ^= c2;
> + c2 ^= c1;
> + c1 ^= c2;
I know this is just code motion, but is it really that hard to just
write the more straightforward:
int tmp = c1;
c1 = c2;
c2 = tmp;
which probably optimizes better in the compiler?
--
Eric Blake [email protected] +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
