logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0003-Avoid-use-of-case-ranges.patch (2383B)


  1. From 8d660bf668aa05e9b5cf10f2fe6171c0462ad34d Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Mon, 6 Sep 2021 19:47:41 -0700
  4. Subject: [PATCH] Avoid use of case ranges
  5. ---
  6. pci.c | 39 ++-------------------------------------
  7. vga.c | 5 ++---
  8. 2 files changed, 4 insertions(+), 40 deletions(-)
  9. diff --git a/pci.c b/pci.c
  10. index d37b737..f0cf05b 100644
  11. --- a/pci.c
  12. +++ b/pci.c
  13. @@ -291,46 +291,11 @@ static void pci_device_config_write8(PCIDevice *d, uint32_t addr,
  14. switch(d->config[0x0e]) {
  15. case 0x00:
  16. case 0x80:
  17. - switch(addr) {
  18. - case 0x00:
  19. - case 0x01:
  20. - case 0x02:
  21. - case 0x03:
  22. - case 0x08:
  23. - case 0x09:
  24. - case 0x0a:
  25. - case 0x0b:
  26. - case 0x0e:
  27. - case 0x10 ... 0x27: /* base */
  28. - case 0x30 ... 0x33: /* rom */
  29. - case 0x3d:
  30. - can_write = 0;
  31. - break;
  32. - default:
  33. - can_write = 1;
  34. - break;
  35. - }
  36. + can_write = addr >= 0x40 || 1ull << addr & 0xdff0ff000000b0f0;
  37. break;
  38. default:
  39. case 0x01:
  40. - switch(addr) {
  41. - case 0x00:
  42. - case 0x01:
  43. - case 0x02:
  44. - case 0x03:
  45. - case 0x08:
  46. - case 0x09:
  47. - case 0x0a:
  48. - case 0x0b:
  49. - case 0x0e:
  50. - case 0x38 ... 0x3b: /* rom */
  51. - case 0x3d:
  52. - can_write = 0;
  53. - break;
  54. - default:
  55. - can_write = 1;
  56. - break;
  57. - }
  58. + can_write = addr >= 0x40 || 1ull << addr & 0xd0ffffffffffb0f0;
  59. break;
  60. }
  61. if (can_write)
  62. diff --git a/vga.c b/vga.c
  63. index 948d590..afe4c3f 100644
  64. --- a/vga.c
  65. +++ b/vga.c
  66. @@ -506,9 +506,6 @@ static void vga_ioport_write(VGAState *s, uint32_t addr, uint32_t val)
  67. } else {
  68. index = s->ar_index & 0x1f;
  69. switch(index) {
  70. - case 0x00 ... 0x0f:
  71. - s->ar[index] = val & 0x3f;
  72. - break;
  73. case 0x10:
  74. s->ar[index] = val & ~0x10;
  75. break;
  76. @@ -525,6 +522,8 @@ static void vga_ioport_write(VGAState *s, uint32_t addr, uint32_t val)
  77. s->ar[index] = val & ~0xf0;
  78. break;
  79. default:
  80. + if (index <= 0x0f)
  81. + s->ar[index] = val & 0x3f;
  82. break;
  83. }
  84. }
  85. --
  86. 2.32.0