From 05812f0f3c5ed2009560ad90e7cedf6dc546ba9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Szulik?= Date: Mon, 21 Sep 2020 12:51:42 +0200 Subject: [PATCH] Fix runtime error when there are no NVM devices. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Szulik --- nvm/machine_libipmctl.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nvm/machine_libipmctl.go b/nvm/machine_libipmctl.go index 2eb717b600..1b02faa895 100644 --- a/nvm/machine_libipmctl.go +++ b/nvm/machine_libipmctl.go @@ -57,6 +57,11 @@ func getAvgPowerBudget() (uint, error) { return uint(0), fmt.Errorf("Unable to get number of NVM devices. Status code: %d", err) } + if count == 0 { + klog.Warningf("There are no NVM devices!") + return uint(0), nil + } + // Load basic device information for all the devices // to obtain UID of the first one. devices := make([]C.struct_device_discovery, count)