From 61ab4f256fe5b7553e2d3193cd7b37d6de7ea4d6 Mon Sep 17 00:00:00 2001
From: Brian Christiansen <brian@schedmd.com>
Date: Mon, 28 Aug 2017 14:05:37 -0600
Subject: [PATCH] Fix uninitialized value

reported when compiling with optimizations (-O2). field_id may be
uninitialized or the the value from the previous iteration in the while
loop. The only possible values of dataset_loc->type are:

typedef enum {
	PROFILE_FIELD_NOT_SET,
	PROFILE_FIELD_UINT64,
	PROFILE_FIELD_DOUBLE
} acct_gather_profile_field_type_t;

and the while loop condition ensures that PROFILE_FIELD_NOT_SET is not
handled. So instead of handling PROFILE_FIELD_NOT_SET directly, just
catching everything else with the "default" case statement and
continuing the loop.
---
 .../acct_gather_profile/hdf5/acct_gather_profile_hdf5.c     | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/plugins/acct_gather_profile/hdf5/acct_gather_profile_hdf5.c b/src/plugins/acct_gather_profile/hdf5/acct_gather_profile_hdf5.c
index 4810e8150d5..0d5e841275f 100644
--- a/src/plugins/acct_gather_profile/hdf5/acct_gather_profile_hdf5.c
+++ b/src/plugins/acct_gather_profile/hdf5/acct_gather_profile_hdf5.c
@@ -546,8 +546,10 @@ extern int acct_gather_profile_p_create_dataset(
 			field_id = H5T_NATIVE_DOUBLE;
 			field_size = sizeof(double);
 			break;
-		case PROFILE_FIELD_NOT_SET:
-			break;
+		default:
+			error("%s: unknown field type:%d",
+			      __func__, dataset_loc->type);
+			continue;
 		}
 		if (H5Tinsert(dtype_id, dataset_loc->name,
 			      offset, field_id) < 0)
-- 
GitLab