Linux-rt-users archive mirror
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: RT <linux-rt-users@vger.kernel.org>
Cc: Juri Lelli <juri.lelli@redhat.com>,
	Clark Williams <williams@redhat.com>,
	John Kacur <jkacur@redhat.com>
Subject: [PATCH] rteval: return empty string in compress_cpulist for an  empty list
Date: Thu, 31 Aug 2023 16:27:41 -0400	[thread overview]
Message-ID: <20230831202741.200657-1-jkacur@redhat.com> (raw)

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@redhat.com>
---
 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


                 reply	other threads:[~2023-08-31 20:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230831202741.200657-1-jkacur@redhat.com \
    --to=jkacur@redhat.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).