Skip to content

Commit

Permalink
xcpmd: Check for xenstore_ls return value.
Browse files Browse the repository at this point in the history
xenstore_ls() can fail and return NULL, if Xenstore is not running for
example. Check the value and log a warning in this case.

Signed-off-by: Eric Chanudet <[email protected]>

OXT-1012
  • Loading branch information
Eric Chanudet committed Apr 3, 2017
1 parent 224684e commit 3d04a96
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions xcpmd/src/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ static void make_xenstore_battery_dir(unsigned int battery_index) {
bool flag;

dir_entries = xenstore_ls(&num_entries, "/pm");
if (!dir_entries) {
xcpmd_log(LOG_WARNING,
"Listing directory /pm failed with error `%s'\n", strerror(errno));
return;
}

snprintf(xenstore_path, 255, "%s%i", XS_BATTERY_PATH, battery_index);

flag = false;
Expand Down

0 comments on commit 3d04a96

Please sign in to comment.