mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-24 12:55:41 +02:00
module/battery: convert asserts to real error checks
This commit is contained in:
parent
d81547066d
commit
30332670aa
1 changed files with 5 additions and 2 deletions
|
@ -109,8 +109,10 @@ readline_from_fd(int fd)
|
|||
ssize_t sz = read(fd, buf, sizeof(buf) - 1);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
|
||||
if (sz < 0)
|
||||
if (sz < 0) {
|
||||
LOG_WARN("failed to read from FD=%d", fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buf[sz] = '\0';
|
||||
for (ssize_t i = sz - 1; i >= 0 && buf[i] == '\n'; sz--)
|
||||
|
@ -123,7 +125,8 @@ static long
|
|||
readint_from_fd(int fd)
|
||||
{
|
||||
const char *s = readline_from_fd(fd);
|
||||
assert(s != NULL);
|
||||
if (s == NULL)
|
||||
return 0;
|
||||
|
||||
long ret;
|
||||
int r = sscanf(s, "%ld", &ret);
|
||||
|
|
Loading…
Add table
Reference in a new issue