Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3301 for code/trunk/src/util


Ignore:
Timestamp:
Jul 18, 2009, 4:03:59 PM (15 years ago)
Author:
rgrieder
Message:

Found even more casts. They sure aren't all of them, but I hope to have caught every pointer C-style cast because they can be very dangerous.
Note: I didn't do the pointer casts in the network library because that would have taken way too long.

Location:
code/trunk/src/util
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/util/Clipboard.cc

    r3214 r3301  
    6666                EmptyClipboard();
    6767                HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, text.size() + 1);
    68                 char* buffer = (char*)GlobalLock(clipbuffer);
     68                char* buffer = static_cast<char*>(GlobalLock(clipbuffer));
    6969                strcpy(buffer, text.c_str());
    7070                GlobalUnlock(clipbuffer);
     
    9494            {
    9595                HANDLE hData = GetClipboardData(CF_TEXT);
    96                 std::string output = (char*)GlobalLock(hData);
     96                std::string output = static_cast<char*>(GlobalLock(hData));
    9797                GlobalUnlock(hData);
    9898                CloseClipboard();
  • code/trunk/src/util/MultiType.h

    r3280 r3301  
    303303            inline bool                                   setValue(const char* value);
    304304            /** @brief Assigns a pointer. */
    305             template <typename V> inline bool             setValue(V* value)               { if (this->value_) { return this->value_->setValue((void*)value); } else { return this->assignValue((void*)value); } }
     305            template <typename V> inline bool             setValue(V* value)               { if (this->value_) { return this->value_->setValue(static_cast<void*>(const_cast<typename TypeStripper<V>::RawType*>(value))); } else { return this->assignValue(static_cast<void*>(const_cast<typename TypeStripper<V>::RawType*>(value))); } }
    306306            /** @brief Assigns the value of the other MultiType and converts it to the current type. */
    307307            bool                                          setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
     
    335335           
    336336            /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
    337             inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
     337            inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
    338338            /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
    339             inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*(uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(mem); }
     339            inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); }
    340340            /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
    341341            inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
     
    371371            operator orxonox::Degree()       const;
    372372            /** @brief Returns the current value, converted to a T* pointer. */
    373             template <class T> operator T*() const { return ((T*)this->operator void*()); }
     373            template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); }
    374374
    375375            inline bool getValue(char*                 value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
     
    420420            inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */
    421421            inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */
    422             template <typename T> inline T* getPointer()          const { return ((T*)this->getVoid());                 } /** @brief Returns the current value, converted to a T* pointer. */
     422            template <typename T> inline T* getPointer()          const { return static_cast<T*>(this->getVoid());      } /** @brief Returns the current value, converted to a T* pointer. */
    423423
    424424        private:
  • code/trunk/src/util/OutputHandler.cc

    r2710 r3301  
    9797    void OutputHandler::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
    9898    {
    99         OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device] = level;
     99        OutputHandler::getOutStream().softDebugLevel_[static_cast<unsigned int>(device)] = level;
    100100    }
    101101
     
    107107    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
    108108    {
    109         return OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device];
     109        return OutputHandler::getOutStream().softDebugLevel_[static_cast<unsigned int>(device)];
    110110    }
    111111
  • code/trunk/src/util/SignalHandler.cc

    r3198 r3301  
    203203        dup2( gdbErr[1], STDERR_FILENO );
    204204
    205         execlp( "sh", "sh", "-c", "gdb", (void*)NULL);
     205        execlp( "sh", "sh", "-c", "gdb", static_cast<void*>(NULL));
    206206      }
    207207
  • code/trunk/src/util/StringUtils.cc

    r3300 r3301  
    125125
    126126        size_t quotecount = 0;
    127         size_t quote = (size_t)-1;
     127        size_t quote = static_cast<size_t>(-1);
    128128        while ((quote = getNextQuote(str, quote + 1)) < pos)
    129129        {
Note: See TracChangeset for help on using the changeset viewer.