Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: generate negative device key #2569

Merged
merged 1 commit into from
Sep 23, 2021
Merged

Conversation

Syuparn
Copy link
Contributor

@Syuparn Syuparn commented Sep 2, 2021

Description

Fix VirtualDeviceList#CreateEthernetCard() to always generate negative device keys so that they will not collide with existing keys.

Closes: #2536

Type of change

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. If applicable, please also list any relevant
details for your test configuration.

  • ensure all device have negative device keys in CreateEthernetCard unittest

Test Configuration:

  • Toolchain:
  • SDK:
  • (add more if needed)

Checklist:

  • My code follows the CONTRIBUTION guidelines of
    this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

Closes: vmware#2536

Generated new devices should have negative device keys so that they will not collide with existing keys.

Signed-off-by: Syuparn <s.hello.spagetti@gmail.com>
@vmwclabot
Copy link
Member

@Syuparn, you must sign our contributor license agreement before your changes are merged. Click here to sign the agreement. If you are a VMware employee, read this for further instruction.

@Syuparn
Copy link
Contributor Author

Syuparn commented Sep 2, 2021

rand.Int31() generates a random non-negative integer as int32 directly. This can avoid changing sign by type conversion.

https://pkg.go.dev/math/rand#Int31

@vmwclabot
Copy link
Member

@Syuparn, VMware has approved your signed contributor license agreement.

Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @Syuparn !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CreateEthernetCard may generate a device with positive key
4 participants