Blame SOURCES/papi-coverity.patch

c7ea89
commit 284f25c227d1b6c07e87f6336d3b6ff0533c85d7
c7ea89
Author: William Cohen <wcohen@redhat.com>
c7ea89
Date:   Thu Jan 30 16:20:24 2014 -0500
c7ea89
c7ea89
    Use correct specification for signed and unsigned int
c7ea89
    
c7ea89
    A run of cppcheck showed that some mismatches between the specfications
c7ea89
    for sscanf and the variables being used to store the values.  This corrects
c7ea89
    those minor issues.
c7ea89
c7ea89
diff --git a/src/components/lustre/linux-lustre.c b/src/components/lustre/linux-lustre.c
c7ea89
index 4f4fb7a..46899f2 100644
c7ea89
--- a/src/components/lustre/linux-lustre.c
c7ea89
+++ b/src/components/lustre/linux-lustre.c
c7ea89
@@ -334,13 +334,13 @@ read_lustre_counter( )
c7ea89
 			if (fgets(buffer,BUFSIZ,fff)==NULL) break;
c7ea89
 	
c7ea89
 			if (strstr( buffer, "write_bytes" )) {
c7ea89
-			  sscanf(buffer,"%*s %*d %*s %*s %*d %*d %lld",&fs->write_cntr->value);
c7ea89
-			  SUBDBG("Read %lld write_bytes\n",fs->write_cntr->value);
c7ea89
+			  sscanf(buffer,"%*s %*d %*s %*s %*d %*d %llu",&fs->write_cntr->value);
c7ea89
+			  SUBDBG("Read %llu write_bytes\n",fs->write_cntr->value);
c7ea89
 			}
c7ea89
 	
c7ea89
 			if (strstr( buffer, "read_bytes" )) {
c7ea89
-			  sscanf(buffer,"%*s %*d %*s %*s %*d %*d %lld",&fs->read_cntr->value);
c7ea89
-			  SUBDBG("Read %lld read_bytes\n",fs->read_cntr->value);
c7ea89
+			  sscanf(buffer,"%*s %*d %*s %*s %*d %*d %llu",&fs->read_cntr->value);
c7ea89
+			  SUBDBG("Read %llu read_bytes\n",fs->read_cntr->value);
c7ea89
 			}
c7ea89
 		  }
c7ea89
 		  fclose(fff);
c7ea89
@@ -352,8 +352,8 @@ read_lustre_counter( )
c7ea89
 			if (fgets(buffer,BUFSIZ,fff)==NULL) break;
c7ea89
 	
c7ea89
 			if (strstr( buffer, "read but discarded")) {
c7ea89
-			   sscanf(buffer,"%*s %*s %*s %lld",&fs->readahead_cntr->value);
c7ea89
-			   SUBDBG("Read %lld discared\n",fs->readahead_cntr->value);
c7ea89
+			   sscanf(buffer,"%*s %*s %*s %llu",&fs->readahead_cntr->value);
c7ea89
+			   SUBDBG("Read %llu discared\n",fs->readahead_cntr->value);
c7ea89
 			   break;
c7ea89
 			}
c7ea89
 	  	  }
c7ea89
diff --git a/src/components/net/linux-net.c b/src/components/net/linux-net.c
c7ea89
index ad15d84..ba7563c 100644
c7ea89
--- a/src/components/net/linux-net.c
c7ea89
+++ b/src/components/net/linux-net.c
c7ea89
@@ -240,7 +240,7 @@ read_net_counters( long long *values )
c7ea89
             SUBDBG("Interface <%s> not found\n", ifname);
c7ea89
         } else {
c7ea89
             nf = sscanf( data,
c7ea89
-                "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
c7ea89
+                "%lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld\n",
c7ea89
                 &values[if_bidx + 0],  &values[if_bidx + 1],
c7ea89
                 &values[if_bidx + 2],  &values[if_bidx + 3],
c7ea89
                 &values[if_bidx + 4],  &values[if_bidx + 5],
c7ea89
@@ -251,7 +251,7 @@ read_net_counters( long long *values )
c7ea89
                 &values[if_bidx + 14], &values[if_bidx + 15]);
c7ea89
 
c7ea89
             SUBDBG("\nRead "
c7ea89
-                "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu\n",
c7ea89
+                "%lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld %lld\n",
c7ea89
                 values[if_bidx + 0],  values[if_bidx + 1],
c7ea89
                 values[if_bidx + 2],  values[if_bidx + 3],
c7ea89
                 values[if_bidx + 4],  values[if_bidx + 5],
c7ea89
commit c810cd0d90baead96838145004545cc156b7ab77
c7ea89
Author: James Ralph <ralph@icl.utk.edu>
c7ea89
Date:   Tue Aug 13 14:13:55 2013 -0400
c7ea89
c7ea89
    Close resource leaks
c7ea89
    
c7ea89
    User dcb reported several resource leaks in trac bug #184.
c7ea89
    --------------------
c7ea89
    I just ran the static analysis checker "cppcheck" over the source
c7ea89
    code of papi-5.2.0
c7ea89
    
c7ea89
    It said
c7ea89
    
c7ea89
    1. [linux-memory.c:711]: (error) Resource leak: sys_cpu
c7ea89
    
c7ea89
    2. [papi_preset.c:735]: (error) Resource leak: fp
c7ea89
    
c7ea89
    3. [components/micpower/linux-micpower.c:166]: (error) Resource leak: fp
c7ea89
    
c7ea89
    I've checked them all and they all look like resource leaks to me.
c7ea89
    
c7ea89
    Suggest code rework.
c7ea89
    ----------------------------------
c7ea89
c7ea89
diff --git a/src/components/micpower/linux-micpower.c b/src/components/micpower/linux-micpower.c
c7ea89
index 896e75f..4da4577 100644
c7ea89
--- a/src/components/micpower/linux-micpower.c
c7ea89
+++ b/src/components/micpower/linux-micpower.c
c7ea89
@@ -163,6 +163,7 @@ read_sysfs_file( long long* counts)
c7ea89
 				retval&= fscanf(fp, "%lld %lld %lld", &counts[i], &counts[i+1], &counts[i+2] );
c7ea89
 		}
c7ea89
 
c7ea89
+		fclose(fp);
c7ea89
 		return retval;
c7ea89
 }
c7ea89
 
c7ea89
diff --git a/src/linux-memory.c b/src/linux-memory.c
c7ea89
index 6c69fbd..bf6c420 100644
c7ea89
--- a/src/linux-memory.c
c7ea89
+++ b/src/linux-memory.c
c7ea89
@@ -707,6 +707,7 @@ sparc_sysfs_cpu_attr( char *name, char **result )
c7ea89
 			return 0;
c7ea89
 		}
c7ea89
 	}
c7ea89
+	closedir( sys_cpu );
c7ea89
 	return -1;
c7ea89
 }
c7ea89
 
c7ea89
diff --git a/src/papi_preset.c b/src/papi_preset.c
c7ea89
index 9485793..603c8df 100644
c7ea89
--- a/src/papi_preset.c
c7ea89
+++ b/src/papi_preset.c
c7ea89
@@ -732,12 +732,14 @@ _xml_papi_hwi_setup_all_presets( char *arch, hwi_dev_notes_t * notes )
c7ea89
 
c7ea89
 	if ( !p ) {
c7ea89
 		PAPIERROR( "Couldn't allocate memory for XML parser." );
c7ea89
+		fclose(fp);
c7ea89
 		return ( PAPI_ESYS );
c7ea89
 	}
c7ea89
 	XML_SetElementHandler( p, _xml_start, _xml_end );
c7ea89
 	XML_SetCharacterDataHandler( p, _xml_content );
c7ea89
 	if ( fp == NULL ) {
c7ea89
 		PAPIERROR( "Error opening Preset XML file." );
c7ea89
+		fclose(fp);
c7ea89
 		return ( PAPI_ESYS );
c7ea89
 	}
c7ea89
 
c7ea89
@@ -749,11 +751,13 @@ _xml_papi_hwi_setup_all_presets( char *arch, hwi_dev_notes_t * notes )
c7ea89
 
c7ea89
 		if ( buffer == NULL ) {
c7ea89
 			PAPIERROR( "Couldn't allocate memory for XML buffer." );
c7ea89
+			fclose(fp);
c7ea89
 			return ( PAPI_ESYS );
c7ea89
 		}
c7ea89
 		len = fread( buffer, 1, BUFFSIZE, fp );
c7ea89
 		if ( ferror( fp ) ) {
c7ea89
 			PAPIERROR( "XML read error." );
c7ea89
+			fclose(fp);
c7ea89
 			return ( PAPI_ESYS );
c7ea89
 		}
c7ea89
 		done = feof( fp );
c7ea89
@@ -761,10 +765,13 @@ _xml_papi_hwi_setup_all_presets( char *arch, hwi_dev_notes_t * notes )
c7ea89
 			PAPIERROR( "Parse error at line %d:\n%s\n",
c7ea89
 					   XML_GetCurrentLineNumber( p ),
c7ea89
 					   XML_ErrorString( XML_GetErrorCode( p ) ) );
c7ea89
+			fclose(fp);
c7ea89
 			return ( PAPI_ESYS );
c7ea89
 		}
c7ea89
-		if ( error )
c7ea89
+		if ( error ) {
c7ea89
+			fclose(fp);
c7ea89
 			return ( PAPI_ESYS );
c7ea89
+		}
c7ea89
 	} while ( !done );
c7ea89
 	XML_ParserFree( p );
c7ea89
 	fclose( fp );
c7ea89
commit e5b335740fad31cd230295508f2a4e9fb77a2878
c7ea89
Author: James Ralph <ralph@icl.utk.edu>
c7ea89
Date:   Fri Nov 8 15:15:28 2013 -0500
c7ea89
c7ea89
    multiplex_cost: check return value on PAPI_set_opt
c7ea89
    
c7ea89
    Thanks to Will Cohen for reporting based upon output of coverity.
c7ea89
c7ea89
diff --git a/src/utils/multiplex_cost.c b/src/utils/multiplex_cost.c
c7ea89
index 8fbd7a4..2f8216a 100644
c7ea89
--- a/src/utils/multiplex_cost.c
c7ea89
+++ b/src/utils/multiplex_cost.c
c7ea89
@@ -112,7 +112,8 @@ init_test(int SoftwareMPX, int KernelMPX, int* Events)
c7ea89
   option.multiplex.eventset = SoftwareMPX;
c7ea89
   option.multiplex.ns = itimer.itimer.ns;
c7ea89
 
c7ea89
-  PAPI_set_opt( PAPI_MULTIPLEX, &option );
c7ea89
+  if ( (retval = PAPI_set_opt( PAPI_MULTIPLEX, &option )) != PAPI_OK )
c7ea89
+      test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval);
c7ea89
 
c7ea89
   for (i = 0; i < options.min - 1; i++) {
c7ea89
 	if ( options.kernel_mpx ) {
c7ea89
@@ -249,7 +250,8 @@ main( int argc, char **argv )
c7ea89
   option.multiplex.eventset = SoftwareMPX;
c7ea89
   option.multiplex.ns = itimer.itimer.ns;
c7ea89
 
c7ea89
-  PAPI_set_opt( PAPI_MULTIPLEX, &option );
c7ea89
+  if ( PAPI_OK != (retval = PAPI_set_opt( PAPI_MULTIPLEX, &option )))
c7ea89
+      test_fail( __FILE__, __LINE__, "PAPI_set_opt", retval);
c7ea89
 
c7ea89
   if ( !options.kernel_mpx && !options.force_sw ) {
c7ea89
 	test_fail(__FILE__, __LINE__, "No tests to run.", -1);
c7ea89
commit 83c31e25409040aac8178a4a3f89111efd060cc0
c7ea89
Author: James Ralph <ralph@icl.utk.edu>
c7ea89
Date:   Fri Nov 8 16:10:18 2013 -0500
c7ea89
c7ea89
    perf_event.c: Check return value of ioctl
c7ea89
    
c7ea89
    Thanks to Will Cohen for reporting based upon output of coverity.
c7ea89
c7ea89
diff --git a/src/components/perf_event/perf_event.c b/src/components/perf_event/perf_event.c
c7ea89
index 4b52cce..b4b2656 100644
c7ea89
--- a/src/components/perf_event/perf_event.c
c7ea89
+++ b/src/components/perf_event/perf_event.c
c7ea89
@@ -1909,7 +1909,9 @@ _pe_dispatch_timer( int n, hwd_siginfo_t *info, void *uc)
c7ea89
     return;
c7ea89
   }
c7ea89
         
c7ea89
-  ioctl( fd, PERF_EVENT_IOC_DISABLE, NULL );
c7ea89
+  if (ioctl( fd, PERF_EVENT_IOC_DISABLE, NULL ) == -1 ) {
c7ea89
+      PAPIERROR("ioctl(PERF_EVENT_IOC_DISABLE) failed.\n");
c7ea89
+  }
c7ea89
 
c7ea89
   if ( ( thread->running_eventset[cidx]->state & PAPI_PROFILING ) && 
c7ea89
        !( thread->running_eventset[cidx]->profile.flags & 
c7ea89
commit 60fb1dd4497df7d0ea77d88f586142ceb3e22b32
c7ea89
Author: James Ralph <ralph@icl.utk.edu>
c7ea89
Date:   Thu Nov 21 13:18:49 2013 -0500
c7ea89
c7ea89
    command_line utility: Initialize a variable
c7ea89
    
c7ea89
    Initialize data_type to PAPI_DATATYPE_INT64
c7ea89
    Addresses a coverity error
c7ea89
    Error: COMPILER_WARNING: [#def19]
c7ea89
    papi-5.2.0/src/utils/command_line.c:133:4: warning: 'data_type' may be used uninitialized in this function [-Wmaybe-uninitialized]
c7ea89
    switch (data_type) {
c7ea89
            ^
c7ea89
c7ea89
diff --git a/src/utils/command_line.c b/src/utils/command_line.c
c7ea89
index 36f7df5..2f4a816 100644
c7ea89
--- a/src/utils/command_line.c
c7ea89
+++ b/src/utils/command_line.c
c7ea89
@@ -56,7 +56,7 @@ main( int argc, char **argv )
c7ea89
 	char *success;
c7ea89
 	PAPI_event_info_t info;
c7ea89
 	int EventSet = PAPI_NULL;
c7ea89
-	int i, j, data_type, event;
c7ea89
+	int i, j, event, data_type = PAPI_DATATYPE_INT64;
c7ea89
 	int u_format = 0;
c7ea89
 	int hex_format = 0;
c7ea89
 
c7ea89
commit e43b1138296866795c5db1a6dcd123d312af1b46
c7ea89
Author: James Ralph <ralph@icl.utk.edu>
c7ea89
Date:   Wed Jul 23 15:40:47 2014 -0400
c7ea89
c7ea89
    native_avail.c: Bug fixes and updates
c7ea89
    
c7ea89
    Thanks to Gary Mohr
c7ea89
    --------------------------------------------------
c7ea89
    This patch fixes a couple of problems found in the papi_native_avail program.
c7ea89
    
c7ea89
    First change fixes a problem introduced when the -validate option was added.  This
c7ea89
    option causes events to get added to an event set but never removes them.  This change
c7ea89
    will remove them if the add works.  This change also fixes a coverity detected error
c7ea89
    where the return value from PAPI_destroy_eventset was being ignored.
c7ea89
    
c7ea89
    Second change improves the delimitor check when separating the event description from
c7ea89
    the event mask description.  The previous check only looked for a colon but some of the
c7ea89
    event descriptions contain a colon so descriptions would get displayed incorrectly.  The
c7ea89
    new check finds the "masks:" substring which is what papi inserts to separate these two
c7ea89
    descriptions.
c7ea89
    
c7ea89
    Third change adds code to allow the user to enter events of the form pmu:::event or
c7ea89
    pmu::event when using the -e option in the program.
c7ea89
c7ea89
diff --git a/src/utils/native_avail.c b/src/utils/native_avail.c
c7ea89
index 2073ed7..59fc1b4 100644
c7ea89
--- a/src/utils/native_avail.c
c7ea89
+++ b/src/utils/native_avail.c
c7ea89
@@ -227,13 +232,19 @@ parse_unit_masks( PAPI_event_info_t * info )
c7ea89
 	if ( ( pmask = strchr( ptr, ':' ) ) == NULL ) {
c7ea89
 		return ( 0 );
c7ea89
 	}
c7ea89
-	memmove( info->symbol, pmask, ( strlen( pmask ) + 1 ) * sizeof ( char ) );
c7ea89
-	pmask = strchr( info->long_descr, ':' );
c7ea89
-	if ( pmask == NULL )
c7ea89
+	memmove( info->symbol, pmask, ( strlen(pmask) + 1 ) * sizeof(char) );
c7ea89
+
c7ea89
+	//  The description field contains the event description followed by a tag 'masks:'
c7ea89
+	//  and then the mask description (if there was a mask with this event).  The following
c7ea89
+	//  code isolates the mask description part of this information.
c7ea89
+
c7ea89
+	pmask = strstr( info->long_descr, "masks:" );
c7ea89
+	if ( pmask == NULL ) {
c7ea89
 		info->long_descr[0] = 0;
c7ea89
-	else
c7ea89
-		memmove( info->long_descr, pmask + sizeof ( char ),
c7ea89
-				 ( strlen( pmask ) + 1 ) * sizeof ( char ) );
c7ea89
+	} else {
c7ea89
+		pmask += 6;        // bump pointer past 'masks:' identifier in description
c7ea89
+		memmove( info->long_descr, pmask, (strlen(pmask) + 1) * sizeof(char) );
c7ea89
+	}
c7ea89
 	return ( 1 );
c7ea89
 }
c7ea89
 
c7ea89
@@ -295,8 +306,20 @@ main( int argc, char **argv )
c7ea89
 			 "Event name:", info.symbol);
c7ea89
 		 printf( "%-29s|%s|\n", "Description:", info.long_descr );
c7ea89
 
c7ea89
+		  /* handle the PAPI component-style events which have a component:::event type */
c7ea89
+		  char *ptr;
c7ea89
+		  if ((ptr=strstr(flags.name, ":::"))) {
c7ea89
+		    ptr+=3;
c7ea89
+		  /* handle libpfm4-style events which have a pmu::event type event name */
c7ea89
+		  } else if ((ptr=strstr(flags.name, "::"))) {
c7ea89
+		    ptr+=2;
c7ea89
+		  }
c7ea89
+		  else {
c7ea89
+		    ptr=flags.name;
c7ea89
+		  }
c7ea89
+
c7ea89
 		     /* if unit masks exist but none specified, process all */
c7ea89
-		     if ( !strchr( flags.name, ':' ) ) {
c7ea89
+		     if ( !strchr( ptr, ':' ) ) {
c7ea89
 			if ( PAPI_enum_event( &i, PAPI_NTV_ENUM_UMASKS ) == PAPI_OK ) {
c7ea89
 			   printf( "\nUnit Masks:\n" );
c7ea89
 			   do {
c7ea89
commit 74041b3ebcfc69575efb4ff830b9dc2f651b458b
c7ea89
Author: James Ralph <ralph@icl.utk.edu>
c7ea89
Date:   Fri Aug 29 14:44:08 2014 -0400
c7ea89
c7ea89
    event_info utility: address coverity defect
c7ea89
    
c7ea89
    From Gary Mohr
c7ea89
    --------------
c7ea89
    This patch corrects a defect reported by Coverity.  The defect reported
c7ea89
    that the call to PAPI_enum_cmp_event was setting retval which was never
c7ea89
    getting used before it got set again by a call to PAPI_get_event_info.
c7ea89
    
c7ea89
    After looking at the code, I decided that we should not be trying to get
c7ea89
    the next event inside a loop that is enumerating masks for the current
c7ea89
    event.  It makes more sense to break out of the loop to get masks and
c7ea89
    let the outer loop that is walking the events get the next event.
c7ea89
    --------------
c7ea89
c7ea89
diff --git a/src/utils/event_info.c b/src/utils/event_info.c
c7ea89
index d1010b6..1de375f 100644
c7ea89
--- a/src/utils/event_info.c
c7ea89
+++ b/src/utils/event_info.c
c7ea89
@@ -237,8 +237,7 @@ enum_native_events( FILE * f, int cidx)
c7ea89
 		    retval = PAPI_get_event_info( k, &info );
c7ea89
 		    if ( retval == PAPI_OK ) {
c7ea89
 		       if ( test_event( k )!=PAPI_OK ) {
c7ea89
-			 retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cidx );
c7ea89
-			  continue;
c7ea89
+			   break;
c7ea89
 		       }
c7ea89
 		       xmlize_event( f, &info, -1 );
c7ea89
 		    }
c7ea89
commit 07990f85c706221f41d8b27bb2aebfc6c4874dbd
c7ea89
Author: James Ralph <ralph@icl.utk.edu>
c7ea89
Date:   Tue Sep 2 11:54:07 2014 -0400
c7ea89
c7ea89
    ctests/ Address coverity reported defects
c7ea89
    
c7ea89
    Thanks to Gary Mohr for the patch
c7ea89
    ---------------------------------
c7ea89
    he contents of this patch file fix defects reported by Coverity in the
c7ea89
    directory 'papi/src/ctests'.
c7ea89
    
c7ea89
    The defect reported in branches.c was that a comparison between
c7ea89
    different kinds of data was being done.
c7ea89
    
c7ea89
    The defect reported in calibrate.c was that the variable
c7ea89
    'papi_event_str' could end up without a null terminator.
c7ea89
    
c7ea89
    The defects reported in describe.c, get_event_component.c, and
c7ea89
    krentel_pthreads.c were that return values from function calls were
c7ea89
    being stored in a variable but never being used.
c7ea89
    
c7ea89
    I also did a little clean-up in describe.c.  This test had been failing
c7ea89
    for me on Intel NHM and SNBEP but now it runs and reports that it
c7ea89
    PASSED.
c7ea89
    ---------------------------------
c7ea89
c7ea89
diff --git a/src/ctests/branches.c b/src/ctests/branches.c
c7ea89
index 930329e..5292323 100644
c7ea89
--- a/src/ctests/branches.c
c7ea89
+++ b/src/ctests/branches.c
c7ea89
@@ -94,7 +94,7 @@ main( int argc, char **argv )
c7ea89
 	/* Find a reasonable number of iterations (each 
c7ea89
 	 * event active 20 times) during the measurement
c7ea89
 	 */
c7ea89
-	t2 = 10000 * 20 * nevents;	/* Target: 10000 usec/multiplex, 20 repeats */
c7ea89
+	t2 = (long long)(10000 * 20) * nevents;	/* Target: 10000 usec/multiplex, 20 repeats */
c7ea89
 	if ( t2 > 30e6 )
c7ea89
 		test_skip( __FILE__, __LINE__, "This test takes too much time",
c7ea89
 				   retval );
c7ea89
diff --git a/src/ctests/calibrate.c b/src/ctests/calibrate.c
c7ea89
index a3dea0a..e370ba9 100644
c7ea89
--- a/src/ctests/calibrate.c
c7ea89
+++ b/src/ctests/calibrate.c
c7ea89
@@ -160,7 +160,8 @@ main( int argc, char *argv[] )
c7ea89
 				print_help( argv );
c7ea89
 				exit( 1 );
c7ea89
 			}
c7ea89
-			strncpy( papi_event_str, argv[i + 1], sizeof ( papi_event_str ) );
c7ea89
+			strncpy( papi_event_str, argv[i + 1], sizeof ( papi_event_str ) - 1);
c7ea89
+			papi_event_str[sizeof ( papi_event_str )-1] = '\0';
c7ea89
 			i++;
c7ea89
 		} else if ( strstr( argv[i], "-d" ) )
c7ea89
 			double_precision = 1;
c7ea89
diff --git a/src/ctests/describe.c b/src/ctests/describe.c
c7ea89
index d29bf72..f03309e 100644
c7ea89
--- a/src/ctests/describe.c
c7ea89
+++ b/src/ctests/describe.c
c7ea89
@@ -25,7 +25,6 @@ main( int argc, char **argv )
c7ea89
 	int retval;
c7ea89
 	long long g1[2];
c7ea89
 	int eventcode = PAPI_TOT_INS;
c7ea89
-	char eventname[PAPI_MAX_STR_LEN];
c7ea89
 	PAPI_event_info_t info, info1, info2;
c7ea89
 
c7ea89
 	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */
c7ea89
@@ -52,18 +51,19 @@ main( int argc, char **argv )
c7ea89
 		test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
c7ea89
 
c7ea89
 	/* Case 0, no info, should fail */
c7ea89
-	eventname[0] = '\0';
c7ea89
 	eventcode = 0;
c7ea89
 /*
c7ea89
    if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) == PAPI_OK)
c7ea89
      test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);	   
c7ea89
 */
c7ea89
+	if (!TESTS_QUIET) {
c7ea89
+	    printf("This test expects a 'PAPI Error' to be returned from this PAPI call.\n");
c7ea89
+	}
c7ea89
 	if ( ( retval = PAPI_get_event_info( eventcode, &info ) ) == PAPI_OK )
c7ea89
 		test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
c7ea89
 
c7ea89
 	/* Case 1, fill in name field. */
c7ea89
 	eventcode = PAPI_TOT_INS;
c7ea89
-	eventname[0] = '\0';
c7ea89
 /*
c7ea89
    if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) != PAPI_OK)
c7ea89
      test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);	   
c7ea89
@@ -85,11 +85,9 @@ main( int argc, char **argv )
c7ea89
    if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) != PAPI_OK)
c7ea89
      test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);	   
c7ea89
 */
c7ea89
-	strcpy( eventname, info1.symbol );
c7ea89
-	if ( ( retval =
c7ea89
-		   PAPI_event_name_to_code( eventname,
c7ea89
-									( int * ) &eventcode ) ) != PAPI_OK )
c7ea89
+	if ( ( retval = PAPI_event_name_to_code( info1.symbol, ( int * ) &eventcode ) ) != PAPI_OK ) {
c7ea89
 		test_fail( __FILE__, __LINE__, "PAPI_event_name_to_code", retval );
c7ea89
+	}
c7ea89
 
c7ea89
 	if ( eventcode != PAPI_TOT_INS )
c7ea89
 		test_fail( __FILE__, __LINE__,
c7ea89
diff --git a/src/ctests/get_event_component.c b/src/ctests/get_event_component.c
c7ea89
index ae1bdd9..874f394 100644
c7ea89
--- a/src/ctests/get_event_component.c
c7ea89
+++ b/src/ctests/get_event_component.c
c7ea89
@@ -42,8 +42,7 @@ main( int argc, char **argv )
c7ea89
             test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
c7ea89
          }
c7ea89
 
c7ea89
-         if (cmpinfo->disabled)
c7ea89
-         {
c7ea89
+         if (cmpinfo->disabled && !TESTS_QUIET) {
c7ea89
            printf( "Name:   %-23s %s\n", cmpinfo->name ,cmpinfo->description);
c7ea89
            printf("   \\-> Disabled: %s\n",cmpinfo->disabled_reason);
c7ea89
            continue;
c7ea89
@@ -55,7 +54,12 @@ main( int argc, char **argv )
c7ea89
        if (retval!=PAPI_OK) continue;
c7ea89
 
c7ea89
        do {
c7ea89
-          retval = PAPI_get_event_info( i, &info );
c7ea89
+	   if (PAPI_get_event_info( i, &info ) != PAPI_OK) {
c7ea89
+	       if (!TESTS_QUIET) {
c7ea89
+		   printf("Getting information about event: %#x failed\n", i);
c7ea89
+	       }
c7ea89
+	       continue;
c7ea89
+	   }
c7ea89
 	  our_cid=PAPI_get_event_component(i);
c7ea89
 
c7ea89
 	  if (our_cid!=cid) {
c7ea89
diff --git a/src/ctests/krentel_pthreads.c b/src/ctests/krentel_pthreads.c
c7ea89
index a8b97ff..2417976 100644
c7ea89
--- a/src/ctests/krentel_pthreads.c
c7ea89
+++ b/src/ctests/krentel_pthreads.c
c7ea89
@@ -125,11 +125,18 @@ my_thread( void *v )
c7ea89
 	}
c7ea89
 
c7ea89
 	PAPI_stop( EventSet, &value );
c7ea89
-	PAPI_remove_event( EventSet, EVENT );
c7ea89
-	PAPI_destroy_eventset( &EventSet );
c7ea89
+	retval = PAPI_remove_event( EventSet, EVENT );
c7ea89
+	if ( PAPI_OK != retval ) {
c7ea89
+	    test_fail( __FILE__, __LINE__, "PAPI_remove_event", retval );
c7ea89
+	}
c7ea89
+	retval = PAPI_destroy_eventset( &EventSet );
c7ea89
+	if ( PAPI_OK != retval ) {
c7ea89
+	    test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
c7ea89
+	}
c7ea89
 	retval = PAPI_unregister_thread(  );
c7ea89
-	if ( retval != PAPI_OK )
c7ea89
+	if ( PAPI_OK != retval ) {
c7ea89
 		test_fail( __FILE__, __LINE__, "PAPI_unregister_thread", retval );
c7ea89
+	}
c7ea89
 	return ( NULL );
c7ea89
 }
c7ea89
 
c7ea89
commit 266c61a4d4e5beee43cce7e3ef1d64da202c0b09
c7ea89
Author: James Ralph <ralph@icl.utk.edu>
c7ea89
Date:   Fri Sep 19 17:46:42 2014 -0400
c7ea89
c7ea89
    Address coverity reported issues in src/
c7ea89
    
c7ea89
    Thanks to Gary Mohr
c7ea89
    -------------------
c7ea89
    Changes in this patch file:
c7ea89
    
c7ea89
    linux-common.c:  Add code to insure that cpu info vendor_string and
c7ea89
        model_string buffers are NULL terminated strings.  Also insure that
c7ea89
        the value which gets read into mdi->exe_info.fullname gets NULL
c7ea89
        terminated. This makes it safe to use the  'strxxx' functions on the
c7ea89
        value (which is done immediately after it is read in).
c7ea89
    
c7ea89
    papi_hl.c:  Fix call to _hl_rate_calls() where the third argument was
c7ea89
        not the correct data type.
c7ea89
    
c7ea89
    papi_internal.c:  Add code to insure that event info name, short_desc,
c7ea89
        and long_desc buffers are NULL terminated strings.
c7ea89
    
c7ea89
    papi_user_events.c:  While processing define symbols, insure that the
c7ea89
        'local_line', 'name', and 'value'
c7ea89
        buffers get NULL terminated (so we can safely use
c7ea89
    	    'strxxx' functions on them).
c7ea89
        Insure that the 'symbol' field in the user defined
c7ea89
        event ends up NULL terminated.
c7ea89
        Rearrange code to avoid falling through from one
c7ea89
        case to the next in a switch statement.
c7ea89
        Coverity flagged falling out the bottom of a case
c7ea89
        statement as a potential defect but it
c7ea89
        was doing what it should.
c7ea89
    
c7ea89
    sw_multiplex.c:  Unnecessary test.  The value of ESI can not be NULL
c7ea89
        when this code is reached.
c7ea89
    
c7ea89
    x86_cpuid_info.c:  The variable need_leaf4 is set but not used.  The
c7ea89
        only place it gets set returns without
c7ea89
        checking its value.  The place that checks its value
c7ea89
        never could have set its value non-zero.
c7ea89
c7ea89
diff --git a/src/linux-common.c b/src/linux-common.c
c7ea89
index 4adc232..614a83c 100644
c7ea89
--- a/src/linux-common.c
c7ea89
+++ b/src/linux-common.c
c7ea89
@@ -171,6 +171,7 @@ int
c7ea89
 _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
c7ea89
 {
c7ea89
     int tmp, retval = PAPI_OK;
c7ea89
+    unsigned int strSize;
c7ea89
     char maxargs[PAPI_HUGE_STR_LEN], *t, *s;
c7ea89
     float mhz = 0.0;
c7ea89
     FILE *f;
c7ea89
@@ -197,14 +198,17 @@ _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
c7ea89
        /* Vendor Name and Vendor Code */
c7ea89
     rewind( f );
c7ea89
     s = search_cpu_info( f, "vendor_id", maxargs );
c7ea89
+    strSize = sizeof(hwinfo->vendor_string);
c7ea89
     if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
c7ea89
        *t = '\0';
c7ea89
+       if (strlen(s+2) >= strSize-1)     s[strSize+1] = '\0';
c7ea89
        strcpy( hwinfo->vendor_string, s + 2 );
c7ea89
     } else {
c7ea89
        rewind( f );
c7ea89
        s = search_cpu_info( f, "vendor", maxargs );
c7ea89
        if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
c7ea89
 	  *t = '\0';
c7ea89
+     if (strlen(s+2) >= strSize-1)     s[strSize+1] = '\0';
c7ea89
 	  strcpy( hwinfo->vendor_string, s + 2 );
c7ea89
        } else {
c7ea89
 	  rewind( f );
c7ea89
@@ -212,6 +216,7 @@ _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
c7ea89
 	  if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
c7ea89
 	     *t = '\0';
c7ea89
 	     s = strtok( s + 2, " " );
c7ea89
+        if (strlen(s) >= strSize-1)     s[strSize-1] = '\0';
c7ea89
 	     strcpy( hwinfo->vendor_string, s );
c7ea89
 	  } else {
c7ea89
 	     rewind( f );
c7ea89
@@ -258,14 +263,17 @@ _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
c7ea89
        /* Model Name */
c7ea89
     rewind( f );
c7ea89
     s = search_cpu_info( f, "model name", maxargs );
c7ea89
+    strSize = sizeof(hwinfo->model_string);
c7ea89
     if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
c7ea89
        *t = '\0';
c7ea89
+       if (strlen(s+2) >= strSize-1)     s[strSize+1] = '\0';
c7ea89
        strcpy( hwinfo->model_string, s + 2 );
c7ea89
     } else {
c7ea89
        rewind( f );
c7ea89
        s = search_cpu_info( f, "family", maxargs );
c7ea89
        if ( s && ( t = strchr( s + 2, '\n' ) ) ) {
c7ea89
 	  *t = '\0';
c7ea89
+     if (strlen(s+2) >= strSize-1)     s[strSize+1] = '\0';
c7ea89
 	  strcpy( hwinfo->model_string, s + 2 );
c7ea89
        } else {
c7ea89
 	  rewind( f );
c7ea89
@@ -274,6 +282,7 @@ _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
c7ea89
 	     *t = '\0';
c7ea89
 	     strtok( s + 2, " " );
c7ea89
 	     s = strtok( NULL, " " );
c7ea89
+        if (strlen(s) >= strSize-1)     s[strSize-1] = '\0';
c7ea89
 	     strcpy( hwinfo->model_string, s );
c7ea89
 	  } else {
c7ea89
 	     rewind( f );
c7ea89
@@ -282,6 +291,7 @@ _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
c7ea89
 		*t = '\0';
c7ea89
 		/* get just the first token */
c7ea89
 		s = strtok( s + 2, " " );
c7ea89
+	if (strlen(s) >= strSize-1)     s[strSize-1] = '\0';
c7ea89
 		strcpy( hwinfo->model_string, s );
c7ea89
 	     }
c7ea89
 	  }
c7ea89
@@ -444,15 +454,18 @@ _linux_get_system_info( papi_mdi_t *mdi ) {
c7ea89
 	mdi->pid = pid;
c7ea89
 
c7ea89
 	sprintf( maxargs, "/proc/%d/exe", ( int ) pid );
c7ea89
-	if ( readlink( maxargs, mdi->exe_info.fullname, PAPI_HUGE_STR_LEN ) < 0 ) {
c7ea89
+   if ( (retval = readlink( maxargs, mdi->exe_info.fullname, PAPI_HUGE_STR_LEN-1 )) < 0 ) {
c7ea89
 		PAPIERROR( "readlink(%s) returned < 0", maxargs );
c7ea89
 		return PAPI_ESYS;
c7ea89
 	}
c7ea89
+   if (retval > PAPI_HUGE_STR_LEN-1)   retval=PAPI_HUGE_STR_LEN-1;
c7ea89
+   mdi->exe_info.fullname[retval] = '\0';
c7ea89
 
c7ea89
 	/* Careful, basename can modify it's argument */
c7ea89
 
c7ea89
 	strcpy( maxargs, mdi->exe_info.fullname );
c7ea89
-	strcpy( mdi->exe_info.address_info.name, basename( maxargs ) );
c7ea89
+   strncpy( mdi->exe_info.address_info.name, basename( maxargs ), PAPI_HUGE_STR_LEN-1);
c7ea89
+   mdi->exe_info.address_info.name[PAPI_HUGE_STR_LEN-1] = '\0';
c7ea89
 
c7ea89
 	SUBDBG( "Executable is %s\n", mdi->exe_info.address_info.name );
c7ea89
 	SUBDBG( "Full Executable is %s\n", mdi->exe_info.fullname );
c7ea89
diff --git a/src/papi_hl.c b/src/papi_hl.c
c7ea89
index 19111e7..4fcfe23 100644
c7ea89
--- a/src/papi_hl.c
c7ea89
+++ b/src/papi_hl.c
c7ea89
@@ -204,13 +204,13 @@ int
c7ea89
 PAPI_flips( float *rtime, float *ptime, long long *flpins, float *mflips )
c7ea89
 {
c7ea89
 	int retval;
c7ea89
-	int events = PAPI_FP_INS;
c7ea89
+   int events[1] = {PAPI_FP_INS};
c7ea89
 	long long values = 0;
c7ea89
 
c7ea89
 	if ( rtime == NULL || ptime == NULL || flpins == NULL || mflips == NULL )
c7ea89
 		return PAPI_EINVAL;
c7ea89
 
c7ea89
-	retval = _hl_rate_calls( rtime, ptime, &events, &values, flpins, mflips, HL_FLIP );
c7ea89
+   retval = _hl_rate_calls( rtime, ptime, events, &values, flpins, mflips, HL_FLIP );
c7ea89
 	return ( retval );
c7ea89
 }
c7ea89
 
c7ea89
@@ -259,13 +259,13 @@ int
c7ea89
 PAPI_flops( float *rtime, float *ptime, long long *flpops, float *mflops )
c7ea89
 {
c7ea89
 	int retval;
c7ea89
-	int events = PAPI_FP_OPS;
c7ea89
+   int events[1] = {PAPI_FP_OPS};
c7ea89
 	long long values = 0;
c7ea89
 
c7ea89
 	if ( rtime == NULL || ptime == NULL || flpops == NULL || mflops == NULL )
c7ea89
 		return PAPI_EINVAL;
c7ea89
 
c7ea89
-	retval = _hl_rate_calls( rtime, ptime, &events, &values, flpops, mflops, HL_FLOP );
c7ea89
+   retval = _hl_rate_calls( rtime, ptime, events, &values, flpops, mflops, HL_FLOP );
c7ea89
 	return ( retval );
c7ea89
 }
c7ea89
 
c7ea89
diff --git a/src/papi_internal.c b/src/papi_internal.c
c7ea89
index d354b76..3c51717 100644
c7ea89
--- a/src/papi_internal.c
c7ea89
+++ b/src/papi_internal.c
c7ea89
@@ -2162,20 +2162,22 @@ _papi_hwi_get_preset_event_info( int EventCode, PAPI_event_info_t * info )
c7ea89
 	unsigned int j;
c7ea89
 
c7ea89
 	if ( _papi_hwi_presets[i].symbol ) {	/* if the event is in the preset table */
c7ea89
-	   /* set whole structure to 0 */
c7ea89
+      // since we are setting the whole structure to zero the strncpy calls below will 
c7ea89
+      // be leaving NULL terminates strings as long as they copy 1 less byte than the 
c7ea89
+      // buffer size of the field.
c7ea89
 	   memset( info, 0, sizeof ( PAPI_event_info_t ) );
c7ea89
 
c7ea89
 	   info->event_code = ( unsigned int ) EventCode;
c7ea89
 	   strncpy( info->symbol, _papi_hwi_presets[i].symbol,
c7ea89
-		    sizeof(info->symbol));
c7ea89
+	    sizeof(info->symbol)-1);
c7ea89
 
c7ea89
 	   if ( _papi_hwi_presets[i].short_descr != NULL )
c7ea89
 	      strncpy( info->short_descr, _papi_hwi_presets[i].short_descr,
c7ea89
-				          sizeof ( info->short_descr ) );
c7ea89
+		          sizeof ( info->short_descr )-1 );
c7ea89
 
c7ea89
 	   if ( _papi_hwi_presets[i].long_descr != NULL )
c7ea89
 	      strncpy( info->long_descr,  _papi_hwi_presets[i].long_descr,
c7ea89
-				          sizeof ( info->long_descr ) );
c7ea89
+		          sizeof ( info->long_descr )-1 );
c7ea89
 
c7ea89
 	   info->event_type = _papi_hwi_presets[i].event_type;
c7ea89
 	   info->count = _papi_hwi_presets[i].count;
c7ea89
@@ -2185,17 +2187,17 @@ _papi_hwi_get_preset_event_info( int EventCode, PAPI_event_info_t * info )
c7ea89
 
c7ea89
 	   if ( _papi_hwi_presets[i].postfix != NULL )
c7ea89
 	      strncpy( info->postfix, _papi_hwi_presets[i].postfix,
c7ea89
-				          sizeof ( info->postfix ) );
c7ea89
+		          sizeof ( info->postfix )-1 );
c7ea89
 
c7ea89
 	   for(j=0;j < info->count; j++) {
c7ea89
 	      info->code[j]=_papi_hwi_presets[i].code[j];
c7ea89
 	      strncpy(info->name[j], _papi_hwi_presets[i].name[j],
c7ea89
-		      sizeof(info->name[j]));
c7ea89
+	      sizeof(info->name[j])-1);
c7ea89
 	   }
c7ea89
 
c7ea89
 	   if ( _papi_hwi_presets[i].note != NULL ) {
c7ea89
 	      strncpy( info->note, _papi_hwi_presets[i].note,
c7ea89
-				          sizeof ( info->note ) );
c7ea89
+		          sizeof ( info->note )-1 );
c7ea89
 	   }
c7ea89
 
c7ea89
 	   return PAPI_OK;
c7ea89
diff --git a/src/papi_user_events.c b/src/papi_user_events.c
c7ea89
index 04fc4af..b1f124a 100644
c7ea89
--- a/src/papi_user_events.c
c7ea89
+++ b/src/papi_user_events.c
c7ea89
@@ -246,10 +246,11 @@ get_event_line( char **place, FILE * table, char **tmp_perfmon_events_table )
c7ea89
 
c7ea89
 int add_define( char *line, list_t* LIST ) {
c7ea89
   char *t;
c7ea89
-  char local_line[USER_EVENT_OPERATION_LEN];
c7ea89
+  char local_line[USER_EVENT_OPERATION_LEN+1];
c7ea89
   list_t *temp;
c7ea89
 
c7ea89
   strncpy( local_line, line, USER_EVENT_OPERATION_LEN );
c7ea89
+  local_line[USER_EVENT_OPERATION_LEN] = '\0';
c7ea89
 
c7ea89
   temp = (list_t*)papi_malloc(sizeof(list_t));
c7ea89
 
c7ea89
@@ -262,12 +263,14 @@ int add_define( char *line, list_t* LIST ) {
c7ea89
   
c7ea89
   /* next token should be the name */
c7ea89
   t = strtok(NULL, " ");
c7ea89
-  strncpy( temp->name, t, PAPI_MIN_STR_LEN);
c7ea89
+  strncpy( temp->name, t, PAPI_MIN_STR_LEN-1);
c7ea89
+  temp->name[PAPI_MIN_STR_LEN-1] = '\0';
c7ea89
 
c7ea89
   /* next token should be the value */
c7ea89
   t = strtok(NULL," ");
c7ea89
   t[strlen(t)] = '\0';
c7ea89
-  strncpy( temp->value, t, PAPI_MIN_STR_LEN);
c7ea89
+  strncpy( temp->value, t, PAPI_MIN_STR_LEN-1);
c7ea89
+  temp->value[PAPI_MIN_STR_LEN-1] = '\0';
c7ea89
 
c7ea89
   temp->next = LIST->next;
c7ea89
   LIST->next = temp;
c7ea89
@@ -395,12 +398,15 @@ check_preset_events (char *target, user_defined_event_t* ue, int* msi)
c7ea89
 		strcat(ue->operation, temp);
c7ea89
 		ue->events[ue->count++] = _papi_hwi_presets[j].code[0];
c7ea89
 	  } else {
c7ea89
-		op = '-';
c7ea89
 		switch ( _papi_hwi_presets[j].derived_int ) {
c7ea89
 		  case DERIVED_ADD:
c7ea89
 		  case DERIVED_ADD_PS:
c7ea89
-			op = '+';
c7ea89
 		  case DERIVED_SUB:
c7ea89
+	    if (_papi_hwi_presets[j].derived_int == DERIVED_SUB) {
c7ea89
+		op = '-';
c7ea89
+	    } else {
c7ea89
+		op = '+';
c7ea89
+	    }
c7ea89
 			for ( k = 0; k < (int) _papi_hwi_presets[j].count; k++) {
c7ea89
 			  ue->events[ue->count++] = _papi_hwi_presets[j].code[k];
c7ea89
 			  if (k%2)
c7ea89
@@ -574,7 +580,8 @@ load_user_event_table( char *file_name)
c7ea89
 	  goto nextline;
c7ea89
 	} 
c7ea89
 
c7ea89
-	strncpy(foo->symbol, t, PAPI_MIN_STR_LEN);
c7ea89
+   // the entire structure was zeroed so if we only copy one less that what fits in the 'symbol' buffer, it will insure that this buffer is NULL terminated
c7ea89
+   strncpy(foo->symbol, t, PAPI_MIN_STR_LEN-1);
c7ea89
 #ifdef SHOW_LOADS
c7ea89
 	INTDBG("Found a user event named %s\n", foo->symbol );
c7ea89
 #endif
c7ea89
diff --git a/src/sw_multiplex.c b/src/sw_multiplex.c
c7ea89
index 22db6c2..4b2109c 100644
c7ea89
--- a/src/sw_multiplex.c
c7ea89
+++ b/src/sw_multiplex.c
c7ea89
@@ -1136,8 +1136,6 @@ mpx_check( int EventSet )
c7ea89
 	if ( strcmp( _papi_hwi_system_info.hw_info.model_string, "POWER6" ) == 0 ) {
c7ea89
 		unsigned int chk_domain =
c7ea89
 			PAPI_DOM_USER + PAPI_DOM_KERNEL + PAPI_DOM_SUPERVISOR;
c7ea89
-		if ( ESI == NULL )
c7ea89
-			return ( PAPI_ENOEVST );
c7ea89
 
c7ea89
 		if ( ( ESI->domain.domain & chk_domain ) != chk_domain ) {
c7ea89
 			PAPIERROR
c7ea89
diff --git a/src/x86_cpuid_info.c b/src/x86_cpuid_info.c
c7ea89
index dacc021..2527f3c 100644
c7ea89
--- a/src/x86_cpuid_info.c
c7ea89
+++ b/src/x86_cpuid_info.c
c7ea89
@@ -1416,8 +1416,6 @@ init_intel_leaf2( PAPI_mh_info_t * mh_info , int *num_levels)
c7ea89
 	int size;						   /* size of the descriptor table */
c7ea89
 	int last_level = 0;				   /* how many levels in the cache hierarchy */
c7ea89
 
c7ea89
-	int need_leaf4=0;
c7ea89
-
c7ea89
 	/* All of Intel's cache info is in 1 call to cpuid
c7ea89
 	 * however it is a table lookup :(
c7ea89
 	 */
c7ea89
@@ -1459,7 +1457,6 @@ init_intel_leaf2( PAPI_mh_info_t * mh_info , int *num_levels)
c7ea89
 				if ( i ) {	 /* skip the low order byte in eax [0]; it's the count (see above) */
c7ea89
 				   if ( reg.descrip[i] == 0xff ) {
c7ea89
 				      MEMDBG("Warning! PAPI x86_cache: must implement cpuid leaf 4\n");
c7ea89
-				      need_leaf4=1;
c7ea89
 				      return PAPI_ENOSUPP;
c7ea89
 				      /* we might continue instead */
c7ea89
 				      /* in order to get TLB info  */
c7ea89
@@ -1480,9 +1477,6 @@ init_intel_leaf2( PAPI_mh_info_t * mh_info , int *num_levels)
c7ea89
 early_exit:
c7ea89
 	MEMDBG( "# of Levels: %d\n", last_level );
c7ea89
 	*num_levels=last_level;
c7ea89
-	if (need_leaf4) {
c7ea89
-	   return PAPI_ENOSUPP;
c7ea89
-	}
c7ea89
 	return PAPI_OK;
c7ea89
 }
c7ea89