diff options
author | John Levon <john.levon@nutanix.com> | 2021-02-04 18:13:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 18:13:00 +0000 |
commit | d4055f08f2a2db79b080afd6483ff6b4b558c2b2 (patch) | |
tree | 1dab2d1bef6617ce114dd85b2429e8969b3c56d2 /lib | |
parent | 0eff1c579eaf0555e77eb87c39814ec47e52ebf3 (diff) | |
download | libvfio-user-d4055f08f2a2db79b080afd6483ff6b4b558c2b2.zip libvfio-user-d4055f08f2a2db79b080afd6483ff6b4b558c2b2.tar.gz libvfio-user-d4055f08f2a2db79b080afd6483ff6b4b558c2b2.tar.bz2 |
fix vfio_irq_idx_to_str() (#309)
This debug helper wasn't handling all the valid IRQ indexes. Found via ASAN.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/irq.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -40,16 +40,17 @@ #define LM2VFIO_IRQT(type) (type - 1) static const char * -vfio_irq_idx_to_str(int index) { - static const char *s[] = { - [VFIO_PCI_INTX_IRQ_INDEX] = "INTx", - [VFIO_PCI_MSI_IRQ_INDEX] = "MSI", - [VFIO_PCI_MSIX_IRQ_INDEX] = "MSI-X", - }; - - assert(index < VFU_DEV_NUM_IRQS); - - return s[index]; +vfio_irq_idx_to_str(int index) +{ + switch (index) { + case VFIO_PCI_INTX_IRQ_INDEX: return "INTx"; + case VFIO_PCI_MSI_IRQ_INDEX: return "MSI"; + case VFIO_PCI_MSIX_IRQ_INDEX: return "MSI-X"; + case VFIO_PCI_ERR_IRQ_INDEX: return "ERR"; + case VFIO_PCI_REQ_IRQ_INDEX: return "REQ"; + default: + abort(); + } } static long |