Skip to content

Commit

Permalink
test: Fix MAC address calculation
Browse files Browse the repository at this point in the history
The bit masking was using overzealous shift widths, resulting in "always
zero" second and third components.

While at it, improve readability by first shifting and then masking.

Found by Coverity (CID #15239).
  • Loading branch information
martinpitt committed Aug 1, 2017
1 parent 71ae11a commit d7b63b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/common/testvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ def interface(self, number=None):
self.hostnet += 1
result = {
"number": self.offset + number,
"mac": '52:54:01:{:02x}:{:02x}:{:02x}'.format(mac & 0xff0000 >> 24, mac & 0xff00 >> 16, mac & 0xff),
"mac": '52:54:01:{:02x}:{:02x}:{:02x}'.format((mac >> 16) & 0xff, (mac >> 8) & 0xff, mac & 0xff),
"name": "m{0}.cockpit.lan".format(mac),
"mcast": self.network,
"hostnet": "hostnet{0}".format(hostnet)
Expand Down

0 comments on commit d7b63b0

Please sign in to comment.