From 8f2a1ceeedf303ebef96e8eb3c0131088c82b803 Mon Sep 17 00:00:00 2001
From: James Ralph <ralph@icl.utk.edu>
Date: Mon, 11 Aug 2014 09:48:26 -0400
Subject: [PATCH 18/44] error_codes utility: remove internal bits

Remove dependency on _papi_hwi_num_errors, just keep calling
PAPI_strerror until it fails. We shouldn't be using internal symbols
anyways.
---
 src/utils/error_codes.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/utils/error_codes.c b/src/utils/error_codes.c
index 1b683f4..059d311 100644
--- a/src/utils/error_codes.c
+++ b/src/utils/error_codes.c
@@ -29,12 +29,11 @@
  */
 
 #include "papi_test.h"
-extern int _papi_hwi_num_errors;
 
 int
 main( int argc, char **argv )
 {
-	int i;
+	int i=0;
 	int retval;
 
 	tests_quiet( argc, argv );	/* Set TESTS_QUIET variable */
@@ -50,13 +49,19 @@ main( int argc, char **argv )
 			PAPI_VERSION_MINOR( PAPI_VERSION ),
 			PAPI_VERSION_REVISION( PAPI_VERSION ),
 			PAPI_VERSION_INCREMENT( PAPI_VERSION ) );
-	printf( "There are %d error codes defined\n", _papi_hwi_num_errors );
 	printf( "----------------------------------\n" );
-	for (i = 0; i < _papi_hwi_num_errors; i++) {
+	while ( 1 ) {
 		char *errstr;
 		errstr = PAPI_strerror( -i );
+
+		if ( NULL == errstr ) {
+		    break;
+		}
+
 		printf( "Error code %4d: %s\n", -i, errstr );
+		i++;
 	}
+	printf( "There are %d error codes defined\n", i );
 	printf( "----------------------------------\n\n" );
 	exit( 1 );
 }
-- 
2.1.1

