From a3e1fc11e05930a585d7d96b095ddf5b71d0e072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 29 Mar 2008 12:24:19 +0000 Subject: [PATCH] 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 --- src/build/libbe/app/Message.cpp | 39 +++++---- src/build/libbe/app/Messenger.cpp | 132 +++++++++++------------------- 2 files changed, 71 insertions(+), 100 deletions(-) diff --git a/src/build/libbe/app/Message.cpp b/src/build/libbe/app/Message.cpp index 9c54776cdd..159d611dd2 100644 --- a/src/build/libbe/app/Message.cpp +++ b/src/build/libbe/app/Message.cpp @@ -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 */ -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include #include -#include #include #include #include @@ -23,11 +24,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include 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; } } } diff --git a/src/build/libbe/app/Messenger.cpp b/src/build/libbe/app/Messenger.cpp index ddec18b48a..21199de998 100644 --- a/src/build/libbe/app/Messenger.cpp +++ b/src/build/libbe/app/Messenger.cpp @@ -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 -// Standard Includes ----------------------------------------------------------- #include #include #include -// System Includes ------------------------------------------------------------- #include +#include #include #include #include #include -#include +#include #include #include #include #include -// Project Includes ------------------------------------------------------------ -#include -#include -#include "ObjectLocker.h" -#include "TokenSpace.h" +#include +//#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(_a)); BMessenger::Private b(const_cast(_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); } -