Skip to content

move ReadFileNoStat to its own file - #222

Merged
pgier merged 1 commit into
prometheus:masterfrom
pgier:separate_file_readfilenostat
Oct 7, 2019
Merged

move ReadFileNoStat to its own file#222
pgier merged 1 commit into
prometheus:masterfrom
pgier:separate_file_readfilenostat

Conversation

@pgier

@pgier pgier commented Oct 7, 2019

Copy link
Copy Markdown
Collaborator

This allows it to be built on all platforms
Fixes #221

@pgier pgier mentioned this pull request Oct 7, 2019

@dmitshur dmitshur left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For what it's worth, my temporary local fix was bit-for-bit identical, down to same filename, same copyright header and year, other than the maxBufferSize diff:

$ diff <(git diff --cached) <(curl -sL 'https://github.com/prometheus/procfs/pull/222.diff')
3c3
< index 0000000..2a365a6
---
> index 00000000..8051161b
34c34
< +	const maxBufferSize = 1024 * 500
---
> +	const maxBufferSize = 1024 * 512
46c46
< index 8d8ac70..c07de0b 100644
---
> index 8d8ac700..c07de0b6 100644
Comment thread internal/util/readfile.go
// Reads a max file size of 512kB. For files larger than this, a scanner
// should be used.
func ReadFileNoStat(filename string) ([]byte, error) {
const maxBufferSize = 1024 * 512

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It might be worth mentioning in the commit message that this has changed (it was 1024 * 500 before).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, I updated it when I noticed that the comment didn't match the code, and forgot to mention this in the commit message.

This allows it to be built on all platforms
Fixes prometheus#221.
Also, updates the max size to 512k (instead of 500k) to match the comment.

Signed-off-by: Paul Gier <pgier@redhat.com>
@pgier
pgier force-pushed the separate_file_readfilenostat branch from 0f8d9bf to e973cdd Compare October 7, 2019 06:57

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@pgier
pgier merged commit aee1427 into prometheus:master Oct 7, 2019
bobrik pushed a commit to bobrik/procfs that referenced this pull request Jan 14, 2023
Pin object in CI to allow tests to run with rust 1.48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants