summaryrefslogtreecommitdiffstats
path: root/src/usr/trace
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2012-08-24 18:53:41 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-08-29 11:57:31 -0500
commit1ed4e22f87a49f6527931b4c086c6269a92821a8 (patch)
tree9a6f292c8e6e2a7b0309cd5f3359db053f5604a0 /src/usr/trace
parent2da487f7f1a3ef81e37dd3bc987159e1209d0915 (diff)
downloadblackbird-hostboot-1ed4e22f87a49f6527931b4c086c6269a92821a8.tar.gz
blackbird-hostboot-1ed4e22f87a49f6527931b4c086c6269a92821a8.zip
Avoid malloc(0) in trace.
2% of our calls to malloc / free were of size 0 by trace when someone makes a call to trace that has no extra data (ie. just the string). Change-Id: Ifd1e7f5c843f54bc6563ae4acac18faa876be13c Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1580 Tested-by: Jenkins Server Reviewed-by: Van H. Lee <vanlee@us.ibm.com> Reviewed-by: CAMVAN T. NGUYEN <ctnguyen@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/trace')
-rw-r--r--src/usr/trace/trace.C62
1 files changed, 34 insertions, 28 deletions
diff --git a/src/usr/trace/trace.C b/src/usr/trace/trace.C
index f0d2c9ad9..999c3e264 100644
--- a/src/usr/trace/trace.C
+++ b/src/usr/trace/trace.C
@@ -1,26 +1,25 @@
-/* IBM_PROLOG_BEGIN_TAG
- * This is an automatically generated prolog.
- *
- * $Source: src/usr/trace/trace.C $
- *
- * IBM CONFIDENTIAL
- *
- * COPYRIGHT International Business Machines Corp. 2011-2012
- *
- * p1
- *
- * Object Code Only (OCO) source materials
- * Licensed Internal Code Source Materials
- * IBM HostBoot Licensed Internal Code
- *
- * The source code for this program is not published or other-
- * wise divested of its trade secrets, irrespective of what has
- * been deposited with the U.S. Copyright Office.
- *
- * Origin: 30
- *
- * IBM_PROLOG_END_TAG
- */
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/trace/trace.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2011,2012 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
/**
* @file trace.C
*
@@ -659,8 +658,12 @@ void Trace::_trace_adal_write_all(trace_desc_t *io_td,
l_entry_size = ALIGN_4(l_entry_size);
// Allocate buffer for the arguments we're tracing
- void * l_buffer = malloc(l_data_size);
- memset(l_buffer, 0, l_data_size);
+ void * l_buffer = NULL;
+ if (l_data_size)
+ {
+ l_buffer = malloc(l_data_size);
+ memset(l_buffer, 0, l_data_size);
+ }
char * l_ptr = static_cast<char *> (l_buffer);
// Now copy the arguments to the buffer.
@@ -731,9 +734,12 @@ void Trace::_trace_adal_write_all(trace_desc_t *io_td,
sizeof(l_entry));
// Now write the actual data
- writeData(io_td,
- l_buffer,
- l_data_size);
+ if (l_data_size)
+ {
+ writeData(io_td,
+ l_buffer,
+ l_data_size);
+ }
// Now write the size at the end
// Note that fsp-trace assumes this to be a 32 bit long word
OpenPOWER on IntegriCloud