Skip to content

Conversation

@brancz
Copy link
Member

@brancz brancz commented Dec 5, 2024

No description provided.

@brancz brancz force-pushed the parse-modules branch 4 times, most recently from 8a06cd8 to 6faf716 Compare December 5, 2024 12:23
@brancz brancz force-pushed the parse-modules branch 3 times, most recently from 77e881a to 92a915f Compare December 5, 2024 12:42
proc/proc.go Outdated
func parseKernelModules(content []byte) ([]kernelModule, error) {
var (
modules []kernelModule
scanner = bufio.NewScanner(bytes.NewReader(content))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why slurp all the content and then construct a scanner on top of it -- why not construct a scanner directly on top of the file like we did in the old code?

Doesn't really matter since these files should be small but it seems semantically unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

makes sense

proc/proc.go Outdated
return &symmap, nil
type kernelModule struct {
name string
size int
Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a slight preference to being explicit about sizes (e.g. int64 if this can indeed be bigger than 2 GiB)

Copy link
Member Author

Choose a reason for hiding this comment

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

I only went with int because the rest of the codebase used ints where this ends up being used, but let me see how much work it would be to change this.

proc/proc.go Outdated
Comment on lines 215 to 219
if size > int64(math.MinInt32) && size < int64(math.MaxInt32) {
return int(size), nil
}

return 0, fmt.Errorf("size value out of range: %q", sizeStr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the purpose of this check? If you want to enforce that the value is within a 32-bit range, why not call parseInt with bitSize = 32 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

it was to please CodeQL which was complaining about not guarding this.

@brancz brancz force-pushed the parse-modules branch 3 times, most recently from bce0ba7 to b1f1672 Compare December 5, 2024 14:57
@brancz brancz merged commit 7152631 into main Dec 5, 2024
22 checks passed
@brancz brancz deleted the parse-modules branch December 5, 2024 15:06
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.

3 participants