HomeClusterLabs Projects

Refactor: remoted: Use getline() instead of fgets()
4972c69bb275Unpublished

Unpublished Commit ยท Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Refactor: remoted: Use getline() instead of fgets()

getline() allocates a buffer large enough to hold the entire input line,
avoiding the need to worry about LINE_MAX (which glibc doesn't enforce
anyway).

The man page says:
"getline() reads an entire line from stream, storing the address of the
buffer containing the text into *lineptr. The buffer is null-terminated
and includes the newline character, if one was found."

So for each line that we read, either it contains a newline or we've
reached EOF. This makes the line-eating and a bit of the error-checking
unnecessary.

Also define a constant for the file name instead of taking an argument.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Mar 6 2025, 6:00 AM
Parents
rP94686e140c29: Refactor: remoted: Remove more nesting from load_env_vars()
Branches
Unknown
Tags
Unknown

Event Timeline