[PATCH] rteval: return empty string in compress_cpulist for an empty list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If an empty list is passed to the function compress_cpulist in
systopology.py, return an empty string, or else an IndexError will be
triggered.

Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
---
 rteval/systopology.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rteval/systopology.py b/rteval/systopology.py
index aca2dfd03e95..62ad3558e2e5 100644
--- a/rteval/systopology.py
+++ b/rteval/systopology.py
@@ -147,6 +147,8 @@ class CpuList:
     @staticmethod
     def compress_cpulist(cpulist):
         """ return a string representation of cpulist """
+        if not cpulist:
+            return ""
         if isinstance(cpulist[0], int):
             return ",".join(str(e) for e in cpulist)
         return ",".join(cpulist)
-- 
2.40.1




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux