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

TODO: cleanup and refactor iommu logic #5

Open
HikariKnight opened this issue Jun 17, 2024 · 0 comments
Open

TODO: cleanup and refactor iommu logic #5

HikariKnight opened this issue Jun 17, 2024 · 0 comments
Assignees
Labels
todo Needs to be done at some point

Comments

@HikariKnight
Copy link
Owner

HikariKnight commented Jun 17, 2024

Based on feedback from Gnif the iommu probing logic might be able to be cleaned up a bit to avoid deep nesting
something like

func GetDevicesFromGroups(groups []int, related int, pArg *params.Params) []string {
  var output []string:
  if len(groups) == 0)
    return output

  alldevs := NewIOMMU()
  for _, group := range groups {
      if _, iommu_num := alldevs.Groups[group]; !iommu_num {
        errorcheck.ErrorCheck(fmt.Errorf("IOMMU Group %v does not exist", group))
        continue
      }

      .. do stuff ...
  }

  return output
}

and also cleanup with

for ... {
  if (a) {
    // do stuff
    continue;
  }

  if (b) {
    // do stuff
    continue;
  }
}

Writing this here as notes for myself incase i do not get to this before my vacation and the messages get drowned in discord.

The original code was written as it is now, it was easier to follow logic wise for my brain and was slated for a rewrite (which i forgot due to priorities elsewhere).

@HikariKnight HikariKnight self-assigned this Jun 17, 2024
@HikariKnight HikariKnight added the todo Needs to be done at some point label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
todo Needs to be done at some point
Projects
None yet
Development

No branches or pull requests

1 participant