You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by je...@apache.org on 2010/08/11 20:00:21 UTC
svn commit: r984498 - in /trafficserver/traffic/trunk/proxy: CoreUtils.cc
EventName.cc EventName.h TestHook.cc
Author: jesus
Date: Wed Aug 11 18:00:21 2010
New Revision: 984498
URL: http://svn.apache.org/viewvc?rev=984498&view=rev
Log:
Two prototypes (different even) is a bit sloppy. Pull it to a header and
be consistent. Also, some pedantic compilers treat signatures funny on
char buffer[32] arguments (different from caller and callee) so lets go more
traditional C and do (int length, char *buffer). This should be clean and
reusable.
Added:
trafficserver/traffic/trunk/proxy/EventName.h
Modified:
trafficserver/traffic/trunk/proxy/CoreUtils.cc
trafficserver/traffic/trunk/proxy/EventName.cc
trafficserver/traffic/trunk/proxy/TestHook.cc
Modified: trafficserver/traffic/trunk/proxy/CoreUtils.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/CoreUtils.cc?rev=984498&r1=984497&r2=984498&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/CoreUtils.cc (original)
+++ trafficserver/traffic/trunk/proxy/CoreUtils.cc Wed Aug 11 18:00:21 2010
@@ -140,6 +140,7 @@ int program_counter = 0;
#include <math.h>
#include "inktomi++.h"
#include "CoreUtils.h"
+#include "EventName.h"
#endif /* darwin || freebsd || solaris */
#ifdef READ_CORE_WMT
@@ -158,8 +159,6 @@ FILE *fp;
memTable default_memTable = { 0, 0, 0 };
DynArray<struct memTable>arrayMem(&default_memTable, 0);
-char *event_int_to_string(int event, char buffer[32]);
-
const int HDR_HEAP_HDR_SIZE = ROUND(sizeof(HdrHeap), HDR_PTR_SIZE);
HTTPHdrImpl *global_http;
HttpSM *last_seen_http_sm = NULL;
@@ -1038,7 +1037,7 @@ CoreUtils::dump_history(HttpSM * hsm)
printf("%d %d %s", e, r, fileline);
#endif
char buffer[32];
- char *msg = event_int_to_string(e, buffer);
+ const char *msg = event_int_to_string(e, sizeof(buffer), buffer);
printf(" event string: \"%s\"\n", msg);
xfree(fileline);
Modified: trafficserver/traffic/trunk/proxy/EventName.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/EventName.cc?rev=984498&r1=984497&r2=984498&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/EventName.cc (original)
+++ trafficserver/traffic/trunk/proxy/EventName.cc Wed Aug 11 18:00:21 2010
@@ -45,7 +45,7 @@
-------------------------------------------------------------------------*/
const char *
-event_int_to_string(int event, char buffer[32])
+event_int_to_string(int event, int blen, char *buffer)
{
switch (event) {
case -1: return "<no event>";
@@ -105,7 +105,7 @@ event_int_to_string(int event, char buff
default:
if (buffer != NULL) {
- snprintf(buffer, sizeof(buffer), "%d", event);
+ snprintf(buffer, blen, "%d", event);
return buffer;
} else {
return "UNKNOWN_EVENT";
Added: trafficserver/traffic/trunk/proxy/EventName.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/EventName.h?rev=984498&view=auto
==============================================================================
--- trafficserver/traffic/trunk/proxy/EventName.h (added)
+++ trafficserver/traffic/trunk/proxy/EventName.h Wed Aug 11 18:00:21 2010
@@ -0,0 +1,36 @@
+/** @file
+
+ A brief file description
+
+ @section license License
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+/****************************************************************************
+
+ EventName.h
+
+ Description: Stringifying Events
+ ****************************************************************************/
+
+#ifndef _EVENT_NAME_H_
+#define _EVENT_NAME_H_
+
+const char *event_int_to_string(int event, int blen = 0, char *buffer = NULL);
+
+#endif /* _event_name_h_ */
Modified: trafficserver/traffic/trunk/proxy/TestHook.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/TestHook.cc?rev=984498&r1=984497&r2=984498&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/TestHook.cc (original)
+++ trafficserver/traffic/trunk/proxy/TestHook.cc Wed Aug 11 18:00:21 2010
@@ -31,9 +31,9 @@
#include <limits.h>
#include "P_Net.h"
#include "ParseRules.h"
+#include "EventName.h"
volatile int state_machine_count = 0;
-extern const char *event_int_to_string(int event, char buffer[32] = NULL);
struct Globals
{