diff options
author | Eivind Næss <eivnaes@yahoo.com> | 2021-09-20 09:44:50 -0700 |
---|---|---|
committer | Eivind Næss <eivnaes@yahoo.com> | 2021-09-20 09:44:50 -0700 |
commit | cca2985138a03dcdf903bb5a485e0eb8db6a8c3d (patch) | |
tree | 5947fccac3d345a3c90d6b1460d7e271ee293291 /pppd | |
parent | 3f4190bb5c21d5feb0474b8f547e93a7f99d270c (diff) | |
download | ppp-cca2985138a03dcdf903bb5a485e0eb8db6a8c3d.tar.gz |
Fixing compiler warning with GCC, -Wunused-result and write()
Signed-off-by: Eivind Næss <eivnaes@yahoo.com>
Diffstat (limited to 'pppd')
-rw-r--r-- | pppd/utils.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/pppd/utils.c b/pppd/utils.c index fd213c2..e75bb9c 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -819,7 +819,7 @@ lock(char *dev) #else /* LOCKLIB */ char lock_buffer[12]; - int fd, pid, n; + int fd, pid, n, siz; #ifdef SVR4 struct stat sbuf; @@ -906,11 +906,16 @@ lock(char *dev) pid = getpid(); #ifndef LOCK_BINARY + siz = 11; slprintf(lock_buffer, sizeof(lock_buffer), "%10d\n", pid); - write (fd, lock_buffer, 11); + n = write (fd, lock_buffer, siz); #else - write(fd, &pid, sizeof (pid)); + siz = sizeof (pid); + n = write(fd, &pid, siz); #endif + if (n != siz) { + error("Could not write pid to lock file when locking"); + } close(fd); return 0; @@ -934,7 +939,7 @@ relock(int pid) return -1; #else /* LOCKLIB */ - int fd; + int fd, n, siz; char lock_buffer[12]; if (lock_file[0] == 0) @@ -947,11 +952,16 @@ relock(int pid) } #ifndef LOCK_BINARY + siz = 11; slprintf(lock_buffer, sizeof(lock_buffer), "%10d\n", pid); - write (fd, lock_buffer, 11); + n = write (fd, lock_buffer, siz); #else - write(fd, &pid, sizeof(pid)); + siz = sizeof(pid); + n = write(fd, &pid, siz); #endif /* LOCK_BINARY */ + if (n != siz) { + error("Could not write pid to lock file when locking"); + } close(fd); return 0; |