-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
libct/cg: write unified resources line by line #4186
Conversation
@smileusd does this fix your issue? |
2633837
to
d45970c
Compare
-> @smileusd does this fix your issue? |
// is is written line by line. | ||
func WriteFileByLine(dir, file, data string) error { | ||
i := strings.Index(data, "\n") | ||
if i == -1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this special block.
Others LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lifubang theoretically, yes. Practically, I added it here because I was overly cautious to not break anything.
With this block in place, if the input does not contain newlines, we use the very same function as we used before. In other words, unless there's a newline in data
, this commit changes nothing (and it is easy to validate).
It is also easier to read this way (when you debug it, and write a single line, which is the most common scenario, you don't have to read through the code below).
@AkihiroSuda @thaJeztah PTAL |
It has been pointed out that some controllers can not accept multiple lines of output at once. In particular, io.max can only set one device at a time. Practically, the only multi-line resource values we can get come from unified.* -- let's write those line by line. Add a test case. Reported-by: Tao Shen <shentaoskyking@gmail.com> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
It has been pointed out (in #4182) that some controllers can not accept multiple lines of output at once. In particular, io.max can only set one device at a time.
Practically, the only multi-line resource values we can get come from unified.* -- let's write those line by line.
Add a test case.
Reported-by: Tao Shen shentaoskyking@gmail.com
Closes: #4182