Applied patch by Vasilis:

* Fixed warnings in Message.cpp and Messenger.cpp when building with GCC 4.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24643 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-03-29 12:24:19 +00:00
parent 479a926477
commit a3e1fc11e0
2 changed files with 71 additions and 100 deletions

View File

@ -1,19 +1,20 @@
/*
* Copyright 2005-2007, Haiku Inc. All rights reserved.
* Copyright 2005-2008, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Michael Lotz <mmlr@mlotz.ch>
*/
#include <Message.h>
#include <MessageAdapter.h>
#include <MessagePrivate.h>
#include <MessageUtils.h>
#include <TokenSpace.h>
#include <Message.h>
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <Application.h>
#include <AppMisc.h>
#include <BlockCache.h>
#include <Entry.h>
#include <MessageQueue.h>
@ -23,11 +24,11 @@
#include <Rect.h>
#include <String.h>
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <AppMisc.h>
#include <MessageAdapter.h>
#include <MessagePrivate.h>
#include <MessageUtils.h>
#include <TokenSpace.h>
const char *B_SPECIFIER_ENTRY = "specifiers";
@ -384,7 +385,8 @@ BMessage::_PrintToStream(const char* indent) const
case B_STRING_TYPE: {
ssize_t size = *(ssize_t *)pointer;
pointer += sizeof(ssize_t);
printf("string(\"%s\", %ld bytes)\n", (char *)pointer, size);
printf("string(\"%s\", %ld bytes)\n", (char *)pointer,
(long)size);
pointer += size;
break;
}
@ -425,7 +427,7 @@ BMessage::_PrintToStream(const char* indent) const
BPrivate::entry_ref_unflatten(&ref, (char *)pointer, size);
printf("entry_ref(device=%ld, directory=%lld, name=\"%s\", ",
ref.device, ref.directory, ref.name);
(long)ref.device, ref.directory, ref.name);
BPath path(&ref);
printf("path=\"%s\")\n", path.Path());
@ -441,7 +443,7 @@ BMessage::_PrintToStream(const char* indent) const
BMessage message;
const ssize_t size = *(const ssize_t *)pointer;
pointer += sizeof(ssize_t);
if (message.Unflatten((const char *)pointer)!=B_OK) {
if (message.Unflatten((const char *)pointer) != B_OK) {
fprintf(stderr, "couldn't unflatten item %ld\n", i);
break;
}
@ -451,9 +453,10 @@ BMessage::_PrintToStream(const char* indent) const
break;
}
default: {
printf("(type = '%.4s')(size = %ld)\n", (char *)&value, size);
}
default:
printf("(type = '%.4s')(size = %ld)\n", (char *)&value,
(long)size);
break;
}
}
}

View File

@ -1,99 +1,76 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2005, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: Messenger.h
// Author: Ingo Weinhold (bonefish@users.sf.net)
// Description: BMessenger delivers messages to local or remote targets.
//------------------------------------------------------------------------------
/*
* Copyright 2001-2008, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Ingo Weinhold, bonefish@users.sf.net
*/
// debugging
//#define DBG(x) x
#define DBG(x)
#define OUT printf
/*!
\class BMessenger
Delivers messages to local or remote targets.
*/
#include <Messenger.h>
// Standard Includes -----------------------------------------------------------
#include <new>
#include <stdio.h>
#include <string.h>
// System Includes -------------------------------------------------------------
#include <Application.h>
#include <AppMisc.h>
#include <Handler.h>
#include <Looper.h>
#include <LooperList.h>
#include <Message.h>
#include <Messenger.h>
#include <MessageUtils.h>
#include <MessengerPrivate.h>
#include <OS.h>
#include <Roster.h>
#include <TokenSpace.h>
// Project Includes ------------------------------------------------------------
#include <AppMisc.h>
#include <MessageUtils.h>
#include "ObjectLocker.h"
#include "TokenSpace.h"
#include <ObjectLocker.h>
//#include "TokenSpace.h"
// Local Includes --------------------------------------------------------------
// Local Defines ---------------------------------------------------------------
// Globals ---------------------------------------------------------------------
#define DBG(x)
#define OUT printf
using BPrivate::gDefaultTokens;
using BPrivate::gLooperList;
using BPrivate::BLooperList;
using BPrivate::BObjectLocker;
enum {
NOT_IMPLEMENTED = B_ERROR,
};
// #pragma mark -
// constructor
/*! \brief Creates an unitialized BMessenger.
*/
BMessenger::BMessenger()
: fPort(-1),
fHandlerToken(B_NULL_TOKEN),
fTeam(-1),
fPreferredTarget(false)
:
fPort(-1),
fHandlerToken(B_NULL_TOKEN),
fTeam(-1),
fPreferredTarget(false)
{
}
// copy constructor
/*! \brief Creates a BMessenger and initializes it to have the same target
as the supplied messemger.
\param from The messenger to be copied.
*/
BMessenger::BMessenger(const BMessenger &from)
: fPort(from.fPort),
fHandlerToken(from.fHandlerToken),
fTeam(from.fTeam),
fPreferredTarget(from.fPreferredTarget)
:
fPort(from.fPort),
fHandlerToken(from.fHandlerToken),
fTeam(from.fTeam),
fPreferredTarget(from.fPreferredTarget)
{
}
// destructor
/*! \brief Frees all resources associated with this object.
*/
BMessenger::~BMessenger()
@ -101,9 +78,6 @@ BMessenger::~BMessenger()
}
// Operators and misc
// =
/*! \brief Makes this BMessenger a copy of the supplied one.
\param from the messenger to be copied.
@ -121,7 +95,7 @@ BMessenger::operator=(const BMessenger &from)
return *this;
}
// ==
/*! \brief Returns whether this and the supplied messenger have the same
target.
@ -133,12 +107,12 @@ bool
BMessenger::operator==(const BMessenger &other) const
{
// Note: The fTeam fields are not compared.
return (fPort == other.fPort
&& fHandlerToken == other.fHandlerToken
&& fPreferredTarget == other.fPreferredTarget);
return fPort == other.fPort
&& fHandlerToken == other.fHandlerToken
&& fPreferredTarget == other.fPreferredTarget;
}
// IsValid
/*! \brief Returns whether the messenger's target looper does still exist.
It is not checked whether the target handler is also still existing.
@ -149,12 +123,11 @@ BMessenger::operator==(const BMessenger &other) const
bool
BMessenger::IsValid() const
{
port_info info;
// return (fPort >= 0 && get_port_info(fPort, &info) == B_OK);
return (fPort >= 0);
return fPort >= 0;
// for the build version, we don't actually check the port
}
// Team
/*! \brief Returns the ID of the team the messenger's target lives in.
\return The team of the messenger's target.
@ -166,9 +139,6 @@ BMessenger::Team() const
}
//----- Private or reserved -----------------------------------------
// SetTo
/*! \brief Sets the messenger's team, target looper port and handler token.
If \a preferred is \c true, \a token is ignored.
@ -184,11 +154,11 @@ BMessenger::SetTo(team_id team, port_id port, int32 token, bool preferred)
{
fTeam = team;
fPort = port;
fHandlerToken = (preferred ? B_PREFERRED_TOKEN : token);
fHandlerToken = preferred ? B_PREFERRED_TOKEN : token;
fPreferredTarget = preferred;
}
// <
/*! \brief Returns whether the first one of two BMessengers is less than the
second one.
@ -204,22 +174,21 @@ operator<(const BMessenger &_a, const BMessenger &_b)
{
BMessenger::Private a(const_cast<BMessenger&>(_a));
BMessenger::Private b(const_cast<BMessenger&>(_b));
// significance:
// 1. fPort
// 2. fHandlerToken
// 3. fPreferredTarget
// fTeam is insignificant
return (a.Port() < b.Port()
|| a.Port() == b.Port()
&& (a.Token() < b.Token()
|| a.Token() == b.Token()
&& !a.IsPreferredTarget()
&& b.IsPreferredTarget()));
return a.Port() < b.Port()
|| (a.Port() == b.Port()
&& (a.Token() < b.Token()
|| (a.Token() == b.Token()
&& !a.IsPreferredTarget()
&& b.IsPreferredTarget())));
}
// !=
/*! \brief Returns whether two BMessengers have not the same target.
\param a The first messenger.
@ -232,4 +201,3 @@ operator!=(const BMessenger &a, const BMessenger &b)
{
return !(a == b);
}