From 74cb07df4c669a528b2cf11aaee16a03257dc5ef Mon Sep 17 00:00:00 2001
From: James Ralph <ralph@icl.utk.edu>
Date: Fri, 29 Aug 2014 15:15:35 -0400
Subject: [PATCH 24/44] testlib/test_util.c: Check enum return value

Addresses an issue found by Coverity.
Thanks Gary Mohr,
----------------
The changes in this patch file fixes the only defect in the src/testlib
directory.  The defect reported that the return value from a call to
PAPI_enum_cmp_event was being ignored.  This call to enum events is to
get the first event for the component index passed into this function.
It turns out that the function that contains this code is only ever
called by the overflow_allcounters ctest and it only calls once and
always passes a component index of 0 (perf_event).  So I added code to
check the return value and fail the test if an error was returned.
----------------
---
 src/testlib/test_utils.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/testlib/test_utils.c b/src/testlib/test_utils.c
index 5e7abd8..619d12b 100644
--- a/src/testlib/test_utils.c
+++ b/src/testlib/test_utils.c
@@ -809,7 +809,11 @@ enum_add_native_events( int *num_events, int **evtcodes,
      /* For platform independence, always ASK FOR the first event */
      /* Don't just assume it'll be the first numeric value */
      i = 0 | PAPI_NATIVE_MASK;
-     PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cidx );
+     retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cidx );
+     if ( retval != PAPI_OK )
+     {
+	 test_fail( __FILE__, __LINE__, "PAPI_enum_cmp_event", retval );
+     }
 
      do {
         retval = PAPI_get_event_info( i, &info );
-- 
2.1.1

