mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Silence more memcheck issues
This commit is contained in:
parent
1fa08e327b
commit
dd264f83d3
@ -763,7 +763,6 @@ static void check_proc_acpi_sysfs_battery(const char *node,
|
|||||||
bool *have_battery, bool *charging,
|
bool *have_battery, bool *charging,
|
||||||
int *seconds, int *percent)
|
int *seconds, int *percent)
|
||||||
{
|
{
|
||||||
unsigned capacity;
|
|
||||||
char path[1024];
|
char path[1024];
|
||||||
const char *base = proc_acpi_sysfs_battery_path;
|
const char *base = proc_acpi_sysfs_battery_path;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
@ -772,31 +771,30 @@ static void check_proc_acpi_sysfs_battery(const char *node,
|
|||||||
char *val = NULL;
|
char *val = NULL;
|
||||||
bool charge = false;
|
bool charge = false;
|
||||||
bool choose = false;
|
bool choose = false;
|
||||||
|
unsigned capacity = 0;
|
||||||
ssize_t length = 0;
|
ssize_t length = 0;
|
||||||
int maximum = -1;
|
int maximum = -1;
|
||||||
int remaining = -1;
|
int remaining = -1;
|
||||||
int secs = -1;
|
int secs = -1;
|
||||||
int pct = -1;
|
int pct = -1;
|
||||||
|
|
||||||
if (!strstr(node, "BAT"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
path[0] = '\0';
|
path[0] = '\0';
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "%s/%s/%s", base, node, "status");
|
snprintf(path, sizeof(path), "%s/%s/%s", base, node, "status");
|
||||||
|
|
||||||
if (!path_file_exists(path))
|
if (!path_file_exists(path))
|
||||||
return;
|
return;
|
||||||
if (filestream_read_file(path, (void**)&buf, &length) != 1)
|
if (filestream_read_file(path, (void**)&buf, &length) != 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (strstr((char*)buf, "Discharging"))
|
if (buf && strstr((char*)buf, "Discharging"))
|
||||||
*have_battery = true;
|
*have_battery = true;
|
||||||
else if (strstr((char*)buf, "Charging"))
|
else if (buf && strstr((char*)buf, "Charging"))
|
||||||
{
|
{
|
||||||
*have_battery = true;
|
*have_battery = true;
|
||||||
*charging = true;
|
*charging = true;
|
||||||
}
|
}
|
||||||
else if (strstr((char*)buf, "Full"))
|
else if (buf && strstr((char*)buf, "Full"))
|
||||||
*have_battery = true;
|
*have_battery = true;
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
@ -1043,14 +1041,10 @@ static bool frontend_linux_powerstate_check_acpi_sysfs(
|
|||||||
int *seconds, int *percent)
|
int *seconds, int *percent)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
struct RDIR *entry = NULL;
|
|
||||||
bool have_battery = false;
|
bool have_battery = false;
|
||||||
bool have_ac = false;
|
bool have_ac = false;
|
||||||
bool charging = false;
|
bool charging = false;
|
||||||
|
struct RDIR *entry = retro_opendir(proc_acpi_sysfs_battery_path);
|
||||||
*state = FRONTEND_POWERSTATE_NONE;
|
|
||||||
|
|
||||||
entry = retro_opendir(proc_acpi_sysfs_battery_path);
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -1058,8 +1052,13 @@ static bool frontend_linux_powerstate_check_acpi_sysfs(
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
while (retro_readdir(entry))
|
while (retro_readdir(entry))
|
||||||
check_proc_acpi_sysfs_battery(retro_dirent_get_name(entry),
|
{
|
||||||
&have_battery, &charging, seconds, percent);
|
const char *node = retro_dirent_get_name(entry);
|
||||||
|
|
||||||
|
if (node && strstr(node, "BAT"))
|
||||||
|
check_proc_acpi_sysfs_battery(node,
|
||||||
|
&have_battery, &charging, seconds, percent);
|
||||||
|
}
|
||||||
|
|
||||||
retro_closedir(entry);
|
retro_closedir(entry);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user