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