From 7f3380ff1ae809d664b33835267e9278e00d7700 Mon Sep 17 00:00:00 2001 From: Mike Jones Date: Thu, 6 Jun 2013 11:35:21 -0500 Subject: HWPF: Compile time check for adding too much FFDC to ReturnCode Change-Id: I2fd4382329a328d97ddf9f7e3faf39e9db95b67b RTC: 72984 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/4870 Tested-by: Jenkins Server Reviewed-by: Brian H. Horton Reviewed-by: Donald E. Dahle Reviewed-by: A. Patrick Williams III --- src/include/usr/hwpf/fapi/fapiReturnCode.H | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/include') diff --git a/src/include/usr/hwpf/fapi/fapiReturnCode.H b/src/include/usr/hwpf/fapi/fapiReturnCode.H index 235de0206..2986412d3 100644 --- a/src/include/usr/hwpf/fapi/fapiReturnCode.H +++ b/src/include/usr/hwpf/fapi/fapiReturnCode.H @@ -47,6 +47,7 @@ * mjjones 09/19/2012 Add FFDC ID to error info * mjjones 03/22/2013 Support Procedure Callouts * mjjones 05/20/2013 Support Bus Callouts + * mjjones 06/06/2013 Check FFDC size at compile time */ #ifndef FAPIRETURNCODE_H_ @@ -471,8 +472,24 @@ namespace ReturnCodeFfdc { EI_FFDC_SIZE_ECMDDB = 0xffff, // ecmdDataBufferBase EI_FFDC_SIZE_TARGET = 0xfffe, // fapi::Target + EI_FFDC_MAX_SIZE = 0x1000, // Limit regular FFDC capture to 4kb }; + /** + * @brief Compile error if caller tries to add too much FFDC to a ReturnCode + * + * If the unspecialized function template is instantiated, the compile will + * fail due to the construction of an undefined class. If the specialized + * function template is instantiated (done if the FFDC size is not too big), + * the function does nothing and is optimized out + */ + class Error_FfdcTooLargeToCapture; + template void checkFfdcSize() + { + Error_FfdcTooLargeToCapture(); + } + template <> inline void checkFfdcSize() {} + /** * @brief Get FFDC Size * @@ -486,6 +503,7 @@ namespace ReturnCodeFfdc template uint16_t getErrorInfoFfdcSize(const T &) { + checkFfdcSize<(sizeof(T) > EI_FFDC_MAX_SIZE)>(); return sizeof(T); } -- cgit v1.2.3