mirror of https://github.com/aria2/aria2
2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use C++ style cast * src/AsyncNameResolver.cc * src/Base64.h * src/BtBitfieldMessage.cc * src/BtHandshakeMessage.cc * src/DefaultBtMessageFactory.cc * src/DefaultBtProgressInfoFile.cc * src/EpollEventPoll.cc * src/ExpatMetalinkProcessor.cc * src/IteratableChecksumValidator.cc * src/IteratableChunkChecksumValidator.cc * src/MessageDigestHelper.cc * src/Platform.cc * src/RequestGroupMan.cc * src/SingleFileAllocationIterator.cc * src/Sqlite3MozCookieParser.cc * src/XML2SAXMetalinkProcessor.cc * src/Xml2XmlRpcRequestProcessor.cc * src/util.cc * src/util.hpull/1/head
parent
2923682aa6
commit
309d292831
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Use C++ style cast
|
||||
* src/AsyncNameResolver.cc
|
||||
* src/Base64.h
|
||||
* src/BtBitfieldMessage.cc
|
||||
* src/BtHandshakeMessage.cc
|
||||
* src/DefaultBtMessageFactory.cc
|
||||
* src/DefaultBtProgressInfoFile.cc
|
||||
* src/EpollEventPoll.cc
|
||||
* src/ExpatMetalinkProcessor.cc
|
||||
* src/IteratableChecksumValidator.cc
|
||||
* src/IteratableChunkChecksumValidator.cc
|
||||
* src/MessageDigestHelper.cc
|
||||
* src/Platform.cc
|
||||
* src/RequestGroupMan.cc
|
||||
* src/SingleFileAllocationIterator.cc
|
||||
* src/Sqlite3MozCookieParser.cc
|
||||
* src/XML2SAXMetalinkProcessor.cc
|
||||
* src/Xml2XmlRpcRequestProcessor.cc
|
||||
* src/util.cc
|
||||
* src/util.h
|
||||
|
||||
2009-11-15 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Fixed integer potential alignment problem.
|
||||
|
|
|
@ -95,7 +95,9 @@ void AsyncNameResolver::process(fd_set* rfdsPtr, fd_set* wfdsPtr)
|
|||
|
||||
int AsyncNameResolver::getsock(sock_t* sockets) const
|
||||
{
|
||||
return ares_getsock(channel, (int *) sockets, ARES_GETSOCK_MAXNUM);
|
||||
// TODO cast to int* might cause problem with Windows SOCKET?
|
||||
return ares_getsock(channel, reinterpret_cast<int*>(sockets),
|
||||
ARES_GETSOCK_MAXNUM);
|
||||
}
|
||||
|
||||
void AsyncNameResolver::process(ares_socket_t readfd, ares_socket_t writefd)
|
||||
|
|
|
@ -64,7 +64,8 @@ public:
|
|||
static void encode(unsigned char*& result, size_t& rlength,
|
||||
const char* src, size_t slength)
|
||||
{
|
||||
encode(result, rlength, (const unsigned char*)src, slength);
|
||||
encode(result, rlength, reinterpret_cast<const unsigned char*>(src),
|
||||
slength);
|
||||
}
|
||||
|
||||
static std::string encode(const std::string& s);
|
||||
|
@ -84,7 +85,8 @@ public:
|
|||
static void decode(unsigned char*& result, size_t& rlength,
|
||||
const char* src, size_t slength)
|
||||
{
|
||||
decode(result, rlength, (const unsigned char*)src, slength);
|
||||
decode(result, rlength, reinterpret_cast<const unsigned char*>(src),
|
||||
slength);
|
||||
}
|
||||
|
||||
static std::string decode(const std::string& s);
|
||||
|
|
|
@ -66,7 +66,7 @@ BtBitfieldMessage::create(const unsigned char* data, size_t dataLength)
|
|||
bittorrent::assertPayloadLengthGreater(1,dataLength, NAME);
|
||||
bittorrent::assertID(ID, data, NAME);
|
||||
BtBitfieldMessageHandle message(new BtBitfieldMessage());
|
||||
message->setBitfield((unsigned char*)data+1, dataLength-1);
|
||||
message->setBitfield(data+1, dataLength-1);
|
||||
return message;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace aria2 {
|
|||
const std::string BtHandshakeMessage::NAME("handshake");
|
||||
|
||||
const unsigned char* BtHandshakeMessage::BT_PSTR =
|
||||
(const unsigned char*)"BitTorrent protocol";
|
||||
reinterpret_cast<const unsigned char*>("BitTorrent protocol");
|
||||
|
||||
BtHandshakeMessage::BtHandshakeMessage():SimpleBtMessage(ID, NAME)
|
||||
{
|
||||
|
|
|
@ -112,7 +112,7 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL
|
|||
msg = BtHaveMessage::create(data, dataLength);
|
||||
{
|
||||
SharedHandle<BtMessageValidator> v
|
||||
(new IndexBtMessageValidator((BtHaveMessage*)msg.get(),
|
||||
(new IndexBtMessageValidator(static_cast<BtHaveMessage*>(msg.get()),
|
||||
_downloadContext->getNumPieces()));
|
||||
msg->setBtMessageValidator(v);
|
||||
}
|
||||
|
@ -121,7 +121,8 @@ DefaultBtMessageFactory::createBtMessage(const unsigned char* data, size_t dataL
|
|||
msg = BtBitfieldMessage::create(data, dataLength);
|
||||
{
|
||||
SharedHandle<BtMessageValidator> v
|
||||
(new BtBitfieldMessageValidator((BtBitfieldMessage*)msg.get(),
|
||||
(new BtBitfieldMessageValidator
|
||||
(static_cast<BtBitfieldMessage*>(msg.get()),
|
||||
_downloadContext->getNumPieces()));
|
||||
msg->setBtMessageValidator(v);
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ void DefaultBtProgressInfoFile::load()
|
|||
_filename.c_str(), strerror(errno)).str());
|
||||
}
|
||||
unsigned char versionBuf[2];
|
||||
in.read((char*)versionBuf, sizeof(versionBuf));
|
||||
in.read(reinterpret_cast<char*>(versionBuf), sizeof(versionBuf));
|
||||
CHECK_STREAM(in, sizeof(versionBuf));
|
||||
std::string versionHex = util::toHex(versionBuf, sizeof(versionBuf));
|
||||
int version;
|
||||
|
@ -242,7 +242,7 @@ void DefaultBtProgressInfoFile::load()
|
|||
versionHex.c_str()).str());
|
||||
}
|
||||
unsigned char extension[4];
|
||||
in.read((char*)extension, sizeof(extension));
|
||||
in.read(reinterpret_cast<char*>(extension), sizeof(extension));
|
||||
CHECK_STREAM(in, sizeof(extension));
|
||||
bool infoHashCheckEnabled = false;
|
||||
if(extension[3]&1 && isTorrentDownload()) {
|
||||
|
|
|
@ -331,7 +331,7 @@ void EpollEventPoll::poll(const struct timeval& tv)
|
|||
|
||||
if(res > 0) {
|
||||
for(int i = 0; i < res; ++i) {
|
||||
SocketEntry* p = (SocketEntry*)_epEvents[i].data.ptr;
|
||||
SocketEntry* p = reinterpret_cast<SocketEntry*>(_epEvents[i].data.ptr);
|
||||
p->processEvents(_epEvents[i].events);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,8 @@ MetalinkProcessor::parseFromBinaryStream(const SharedHandle<BinaryStream>& binar
|
|||
if(res == 0) {
|
||||
break;
|
||||
}
|
||||
if(XML_Parse(parser, (const char*)buf, res, 0) == XML_STATUS_ERROR) {
|
||||
if(XML_Parse(parser, reinterpret_cast<const char*>(buf), res, 0) ==
|
||||
XML_STATUS_ERROR) {
|
||||
throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK);
|
||||
}
|
||||
readOffset += res;
|
||||
|
|
|
@ -79,7 +79,7 @@ void IteratableChecksumValidator::validateChunk()
|
|||
_ctx->digestUpdate(_buffer, length);
|
||||
_currentOffset += length;
|
||||
if(finished()) {
|
||||
std::string actualChecksum = util::toHex((const unsigned char*)_ctx->digestFinal().c_str(), _ctx->digestLength());
|
||||
std::string actualChecksum = util::toHex(_ctx->digestFinal());
|
||||
if(_dctx->getChecksum() == actualChecksum) {
|
||||
_pieceStorage->markAllPiecesDone();
|
||||
} else {
|
||||
|
@ -109,7 +109,8 @@ void IteratableChecksumValidator::init()
|
|||
{
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
free(_buffer);
|
||||
_buffer = (unsigned char*)util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
|
||||
_buffer = reinterpret_cast<unsigned char*>
|
||||
(util::allocateAlignedMemory(ALIGNMENT, BUFSIZE));
|
||||
#else // !HAVE_POSIX_MEMALIGN
|
||||
delete [] _buffer;
|
||||
_buffer = new unsigned char[BUFSIZE];
|
||||
|
|
|
@ -122,7 +122,8 @@ void IteratableChunkChecksumValidator::init()
|
|||
{
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
free(_buffer);
|
||||
_buffer = (unsigned char*)util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
|
||||
_buffer = reinterpret_cast<unsigned char*>
|
||||
(util::allocateAlignedMemory(ALIGNMENT, BUFSIZE));
|
||||
#else // !HAVE_POSIX_MEMALIGN
|
||||
delete [] _buffer;
|
||||
_buffer = new unsigned char[BUFSIZE];
|
||||
|
@ -166,7 +167,7 @@ std::string IteratableChunkChecksumValidator::digest(off_t offset, size_t length
|
|||
curoffset += r;
|
||||
woffset = 0;
|
||||
}
|
||||
return util::toHex((const unsigned char*)_ctx->digestFinal().c_str(), _ctx->digestLength());
|
||||
return util::toHex(_ctx->digestFinal());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ std::string MessageDigestHelper::digest(MessageDigestContext* ctx,
|
|||
ctx->digestUpdate(BUF, readLength);
|
||||
}
|
||||
std::string rawMD = ctx->digestFinal();
|
||||
return util::toHex((const unsigned char*)rawMD.c_str(), rawMD.size());
|
||||
return util::toHex(rawMD);
|
||||
}
|
||||
|
||||
std::string MessageDigestHelper::digest(const std::string& algo, const std::string& filename)
|
||||
|
@ -123,7 +123,7 @@ std::string MessageDigestHelper::digest(const std::string& algo, const void* dat
|
|||
ctx.digestInit();
|
||||
ctx.digestUpdate(data, length);
|
||||
std::string rawMD = ctx.digestFinal();
|
||||
return util::toHex((const unsigned char*)rawMD.c_str(), rawMD.size());
|
||||
return util::toHex(rawMD);
|
||||
}
|
||||
|
||||
void MessageDigestHelper::digest(unsigned char* md, size_t mdLength,
|
||||
|
|
|
@ -100,7 +100,7 @@ bool Platform::setUp()
|
|||
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
WSADATA wsaData;
|
||||
memset((char*)&wsaData, 0, sizeof(wsaData));
|
||||
memset(reinterpret_cast<char*>(&wsaData), 0, sizeof(wsaData));
|
||||
if (WSAStartup(MAKEWORD(1, 1), &wsaData)) {
|
||||
throw DL_ABORT_EX(MSG_WINSOCK_INIT_FAILD);
|
||||
}
|
||||
|
|
|
@ -204,7 +204,8 @@ static void executeHook(const std::string& command, int gid)
|
|||
LogFactory::getInstance()->error("fork() failed."
|
||||
" Cannot execute user command.");
|
||||
} else if(cpid == 0) {
|
||||
execl(command.c_str(), command.c_str(), util::itos(gid).c_str(), (char*)0);
|
||||
execl(command.c_str(), command.c_str(), util::itos(gid).c_str(),
|
||||
reinterpret_cast<char*>(0));
|
||||
perror(("Could not execute user command: "+command).c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,8 @@ SingleFileAllocationIterator::~SingleFileAllocationIterator()
|
|||
void SingleFileAllocationIterator::init()
|
||||
{
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
_buffer = (unsigned char*)util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
|
||||
_buffer = reinterpret_cast<unsigned char*>
|
||||
(util::allocateAlignedMemory(ALIGNMENT, BUFSIZE));
|
||||
#else
|
||||
_buffer = new unsigned char[BUFSIZE];
|
||||
#endif // HAVE_POSIX_MEMALIGN
|
||||
|
|
|
@ -80,7 +80,7 @@ static int cookieRowMapper(void* data, int rowIndex,
|
|||
);
|
||||
|
||||
if(c.good()) {
|
||||
((std::deque<Cookie>*)data)->push_back(c);
|
||||
reinterpret_cast<std::deque<Cookie>*>(data)->push_back(c);
|
||||
}
|
||||
} catch(RecoverableException& e) {
|
||||
//failed to parse expiry.
|
||||
|
|
|
@ -59,15 +59,17 @@ static void mlStartElement(void* userData, const xmlChar* name, const xmlChar**
|
|||
if(attrs) {
|
||||
const xmlChar** p = attrs;
|
||||
while(*p != 0) {
|
||||
std::string name = (const char*)*p++;
|
||||
std::string name = reinterpret_cast<const char*>(*p);
|
||||
++p;
|
||||
if(*p == 0) {
|
||||
break;
|
||||
}
|
||||
std::string value = util::trim((const char*)*p++);
|
||||
std::string value = util::trim(reinterpret_cast<const char*>(*p));
|
||||
++p;
|
||||
attrmap[name] = value;
|
||||
}
|
||||
}
|
||||
sd->_stm->beginElement((const char*)name, attrmap);
|
||||
sd->_stm->beginElement(reinterpret_cast<const char*>(name), attrmap);
|
||||
if(sd->_stm->needsCharactersBuffering()) {
|
||||
sd->_charactersStack.push_front(std::string());
|
||||
}
|
||||
|
@ -81,7 +83,7 @@ static void mlEndElement(void* userData, const xmlChar* name)
|
|||
characters = util::trim(sd->_charactersStack.front());
|
||||
sd->_charactersStack.pop_front();
|
||||
}
|
||||
sd->_stm->endElement((const char*)name, characters);
|
||||
sd->_stm->endElement(reinterpret_cast<const char*>(name), characters);
|
||||
}
|
||||
|
||||
static void mlCharacters(void* userData, const xmlChar* ch, int len)
|
||||
|
@ -154,7 +156,9 @@ MetalinkProcessor::parseFromBinaryStream(const SharedHandle<BinaryStream>& binar
|
|||
}
|
||||
|
||||
SharedHandle<SessionData> sessionData(new SessionData(_stm));
|
||||
xmlParserCtxtPtr ctx = xmlCreatePushParserCtxt(&mySAXHandler, sessionData.get(), (const char*)buf, res, 0);
|
||||
xmlParserCtxtPtr ctx = xmlCreatePushParserCtxt
|
||||
(&mySAXHandler, sessionData.get(),
|
||||
reinterpret_cast<const char*>(buf), res, 0);
|
||||
try {
|
||||
off_t readOffset = res;
|
||||
while(1) {
|
||||
|
@ -162,12 +166,12 @@ MetalinkProcessor::parseFromBinaryStream(const SharedHandle<BinaryStream>& binar
|
|||
if(res == 0) {
|
||||
break;
|
||||
}
|
||||
if(xmlParseChunk(ctx, (const char*)buf, res, 0) != 0) {
|
||||
if(xmlParseChunk(ctx, reinterpret_cast<const char*>(buf), res, 0) != 0) {
|
||||
throw DL_ABORT_EX(MSG_CANNOT_PARSE_METALINK);
|
||||
}
|
||||
readOffset += res;
|
||||
}
|
||||
xmlParseChunk(ctx, (const char*)buf, 0, 1);
|
||||
xmlParseChunk(ctx, reinterpret_cast<const char*>(buf), 0, 1);
|
||||
} catch(Exception& e) {
|
||||
xmlFreeParserCtxt(ctx);
|
||||
throw;
|
||||
|
|
|
@ -63,15 +63,17 @@ static void mlStartElement(void* userData, const xmlChar* name,
|
|||
if(attrs) {
|
||||
const xmlChar** p = attrs;
|
||||
while(*p != 0) {
|
||||
std::string name = (const char*)*p++;
|
||||
std::string name = reinterpret_cast<const char*>(*p);
|
||||
++p;
|
||||
if(*p == 0) {
|
||||
break;
|
||||
}
|
||||
std::string value = util::trim((const char*)*p++);
|
||||
std::string value = util::trim(reinterpret_cast<const char*>(*p));
|
||||
++p;
|
||||
attrmap[name] = value;
|
||||
}
|
||||
}
|
||||
sd->_stm->beginElement((const char*)name, attrmap);
|
||||
sd->_stm->beginElement(reinterpret_cast<const char*>(name), attrmap);
|
||||
if(sd->_stm->needsCharactersBuffering()) {
|
||||
sd->_charactersStack.push(std::string());
|
||||
}
|
||||
|
@ -85,7 +87,7 @@ static void mlEndElement(void* userData, const xmlChar* name)
|
|||
characters = util::trim(sd->_charactersStack.top());
|
||||
sd->_charactersStack.pop();
|
||||
}
|
||||
sd->_stm->endElement((const char*)name, characters);
|
||||
sd->_stm->endElement(reinterpret_cast<const char*>(name), characters);
|
||||
}
|
||||
|
||||
static void mlCharacters(void* userData, const xmlChar* ch, int len)
|
||||
|
|
|
@ -234,7 +234,8 @@ std::string urlencode(const unsigned char* target, size_t len) {
|
|||
|
||||
std::string urlencode(const std::string& target)
|
||||
{
|
||||
return urlencode((const unsigned char*)target.c_str(), target.size());
|
||||
return urlencode(reinterpret_cast<const unsigned char*>(target.c_str()),
|
||||
target.size());
|
||||
}
|
||||
|
||||
std::string torrentUrlencode(const unsigned char* target, size_t len) {
|
||||
|
@ -763,7 +764,8 @@ std::string toString(const BinaryStreamHandle& binaryStream)
|
|||
std::stringstream strm;
|
||||
char data[2048];
|
||||
while(1) {
|
||||
int32_t dataLength = binaryStream->readData((unsigned char*)data, sizeof(data), strm.tellp());
|
||||
int32_t dataLength = binaryStream->readData
|
||||
(reinterpret_cast<unsigned char*>(data), sizeof(data), strm.tellp());
|
||||
strm.write(data, dataLength);
|
||||
if(dataLength == 0) {
|
||||
break;
|
||||
|
|
|
@ -62,8 +62,8 @@ class BitfieldMan;
|
|||
class BinaryStream;
|
||||
class FileEntry;
|
||||
|
||||
#define STRTOLL(X) strtoll(X, (char**)0, 10)
|
||||
#define STRTOULL(X) strtoull(X, (char**)0, 10)
|
||||
#define STRTOLL(X) strtoll(X, reinterpret_cast<char**>(0), 10)
|
||||
#define STRTOULL(X) strtoull(X, reinterpret_cast<char**>(0), 10)
|
||||
|
||||
#define START_INDEX(OFFSET, PIECE_LENGTH) ((OFFSET)/(PIECE_LENGTH))
|
||||
#define END_INDEX(OFFSET, LENGTH, PIECE_LENGTH) (((OFFSET)+(LENGTH)-1)/(PIECE_LENGTH))
|
||||
|
|
Loading…
Reference in New Issue