[MPlayer-cvslog] r37750 - in trunk/vidix: mach64_vid.c nvidia_vid.c radeon_vid.c s3_vid.c

reimar subversion at mplayerhq.hu
Sat Feb 20 12:02:43 CET 2016


Author: reimar
Date: Sat Feb 20 12:02:42 2016
New Revision: 37750

Log:
Avoid possible negative array indices.

Avoids Coverity warnings.

Modified:
   trunk/vidix/mach64_vid.c
   trunk/vidix/nvidia_vid.c
   trunk/vidix/radeon_vid.c
   trunk/vidix/s3_vid.c

Modified: trunk/vidix/mach64_vid.c
==============================================================================
--- trunk/vidix/mach64_vid.c	Sat Feb 20 11:47:40 2016	(r37749)
+++ trunk/vidix/mach64_vid.c	Sat Feb 20 12:02:42 2016	(r37750)
@@ -429,6 +429,7 @@ static int mach64_probe(int verbose,int
 	const char *dname;
 	idx = find_chip(lst[i].device);
 	if(idx == -1 && force == PROBE_NORMAL) continue;
+	if(idx < 0) idx = 0;
 	dname = pci_device_name(VENDOR_ATI,lst[i].device);
 	dname = dname ? dname : "Unknown chip";
 	mp_msg(MSGT_VO, MSGL_STATUS, "[mach64] Found chip: %s\n",dname);

Modified: trunk/vidix/nvidia_vid.c
==============================================================================
--- trunk/vidix/nvidia_vid.c	Sat Feb 20 11:47:40 2016	(r37749)
+++ trunk/vidix/nvidia_vid.c	Sat Feb 20 12:02:42 2016	(r37750)
@@ -881,9 +881,12 @@ static rivatv_info* info;
 
 static int nv_init(void){
 	int mtrr;
+	int chip;
   info = calloc(1,sizeof(rivatv_info));
   info->control_base = map_phys_mem(pci_info.base0, 0x00C00000 + 0x00008000);
-  info->chip.arch =  nvidia_card_ids[find_chip(pci_info.device)].arch;
+  chip = find_chip(pci_info.device);
+  if (chip < 0) chip = 0;
+  info->chip.arch =  nvidia_card_ids[chip].arch;
   mp_msg(MSGT_VO, MSGL_STATUS, "[nvidia_vid] arch %x register base %p\n",info->chip.arch,info->control_base);
   info->chip.PFIFO  = (uint32_t *) (info->control_base + 0x00002000);
   info->chip.FIFO   = (uint32_t *) (info->control_base + 0x00800000);

Modified: trunk/vidix/radeon_vid.c
==============================================================================
--- trunk/vidix/radeon_vid.c	Sat Feb 20 11:47:40 2016	(r37749)
+++ trunk/vidix/radeon_vid.c	Sat Feb 20 12:02:42 2016	(r37750)
@@ -1225,6 +1225,7 @@ static int radeon_probe(int verbose, int
 	const char *dname;
 	idx = find_chip(lst[i].device);
 	if(idx == -1 && force == PROBE_NORMAL) continue;
+	if(idx < 0) idx = 0;
 	dname = pci_device_name(VENDOR_ATI,lst[i].device);
 	dname = dname ? dname : "Unknown chip";
 	mp_msg(MSGT_VO, MSGL_STATUS, RADEON_MSG" Found chip: %s\n",dname);

Modified: trunk/vidix/s3_vid.c
==============================================================================
--- trunk/vidix/s3_vid.c	Sat Feb 20 11:47:40 2016	(r37749)
+++ trunk/vidix/s3_vid.c	Sat Feb 20 12:02:42 2016	(r37750)
@@ -596,6 +596,7 @@ static int s3_init (void)
 {
   unsigned char cr36;
   int mtrr, videoRam;
+  int chip;
   static unsigned char RamTrioVirge[] = { 4, 0, 3, 8, 2, 6, 1, 0 };
   static unsigned char RamSavage3D[] = { 8, 4, 4, 2 };
   static unsigned char RamSavage4[] = { 2, 4, 8, 12, 16, 32, 64, 32 };
@@ -606,7 +607,9 @@ static int s3_init (void)
 
   info = calloc (1, sizeof (s3_info));
 
-  info->chip.arch = s3_card_ids[find_chip (pci_info.device)].arch;
+  chip = find_chip(pci_info.device);
+  if (chip < 0) chip = 0;
+  info->chip.arch = s3_card_ids[chip].arch;
 
   /* Switch to vga registers */
   OUTPORT8 (0x3c3, INPORT8 (0x3c3) | 0x01);


More information about the MPlayer-cvslog mailing list