commit:     50915ea334727f904294027258283bfeb9931cb3
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  8 12:31:36 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec  8 12:31:36 2025 +0000
URL:        https://gitweb.gentoo.org/proj/steve.git/commit/?id=50915ea3

Use pread() instead of lseek() + read()

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 steve.cxx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/steve.cxx b/steve.cxx
index 2e69a36..812657b 100644
--- a/steve.cxx
+++ b/steve.cxx
@@ -118,9 +118,9 @@ static void steve_get_load(steve_state *state)
 
        if (state->loadavg_fd != -1) {
                char buf[64];
-               ssize_t rd;
+               ssize_t rd = pread(state->loadavg_fd, buf, sizeof(buf) - 1, 0);
 
-               if (lseek(state->loadavg_fd, 0, SEEK_SET) == 0 && (rd = 
read(state->loadavg_fd, &buf, sizeof(buf) - 1)) > 0) {
+               if (rd >= 0) {
                        buf[rd] = 0;
 
                        char *begin = buf;

Reply via email to