lseek() doesn't work on "/proc/apm"
This commit is contained in:
parent
d7a636ecb8
commit
d937453f23
|
@ -254,8 +254,7 @@ static gdouble _battery_get(Battery * battery)
|
||||||
return 0.0 / 0.0;
|
return 0.0 / 0.0;
|
||||||
}
|
}
|
||||||
errno = ENODATA;
|
errno = ENODATA;
|
||||||
if(lseek(battery->fd, 0, SEEK_SET) != 0
|
if((buf_cnt = read(battery->fd, buf, sizeof(buf))) <= 0)
|
||||||
|| (buf_cnt = read(battery->fd, buf, sizeof(buf))) <= 0)
|
|
||||||
{
|
{
|
||||||
error_set("%s: %s", apm, strerror(errno));
|
error_set("%s: %s", apm, strerror(errno));
|
||||||
close(battery->fd);
|
close(battery->fd);
|
||||||
|
@ -267,10 +266,12 @@ static gdouble _battery_get(Battery * battery)
|
||||||
&u, &b, &i) != 8)
|
&u, &b, &i) != 8)
|
||||||
{
|
{
|
||||||
error_set("%s: %s", apm, strerror(errno));
|
error_set("%s: %s", apm, strerror(errno));
|
||||||
close(battery->fd);
|
d = 0.0 / 0.0;
|
||||||
battery->fd = -1;
|
|
||||||
}
|
}
|
||||||
d = b;
|
else
|
||||||
|
d = b;
|
||||||
|
close(battery->fd);
|
||||||
|
battery->fd = -1;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user