From d5d7cfc1c989d3162dbb72f8253eb0b735c6c25b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 7 Sep 2021 20:02:03 +0100 Subject: Add -Wold-style-cast --- Jamroot.jam | 1 + icespider/fileSessions/fileSessions.cpp | 4 ++-- icespider/xslt/xsltStreamSerializer.cpp | 13 +++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Jamroot.jam b/Jamroot.jam index 481b28c..a6e17a5 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -18,6 +18,7 @@ project debug:extra debug:on debug:-Wnon-virtual-dtor + debug:-Wold-style-cast debug:-Wcast-align debug:-Wunused debug:-Woverloaded-virtual diff --git a/icespider/fileSessions/fileSessions.cpp b/icespider/fileSessions/fileSessions.cpp index 2b1acbe..1fcdd24 100644 --- a/icespider/fileSessions/fileSessions.cpp +++ b/icespider/fileSessions/fileSessions.cpp @@ -107,8 +107,8 @@ namespace IceSpider { try { AdHoc::FileUtils::MemMap f(path); sysassert(flock(f.fh, LOCK_SH), -1); - auto fbuf = (Ice::Byte *)f.data; - Ice::InputStream buf(ic, std::make_pair(fbuf, fbuf + f.getStat().st_size)); + auto fbuf = f.sv(); + Ice::InputStream buf(ic, std::make_pair(fbuf.begin(), fbuf.end())); SessionPtr s; buf.read(s); sysassert(flock(f.fh, LOCK_UN), -1); diff --git a/icespider/xslt/xsltStreamSerializer.cpp b/icespider/xslt/xsltStreamSerializer.cpp index b6dc44c..17f200b 100644 --- a/icespider/xslt/xsltStreamSerializer.cpp +++ b/icespider/xslt/xsltStreamSerializer.cpp @@ -8,14 +8,14 @@ namespace IceSpider { static int xmlstrmclosecallback(void * context) { - ((std::ostream *)context)->flush(); + static_cast(context)->flush(); return 0; } static int xmlstrmwritecallback(void * context, const char * buffer, int len) { - ((std::ostream *)context)->write(buffer, len); + static_cast(context)->write(buffer, len); return len; } @@ -37,7 +37,7 @@ namespace IceSpider { if (stylesheet) { xsltFreeStylesheet(stylesheet); } - stylesheet = xsltParseStylesheetFile(BAD_CAST stylesheetPath.c_str()); + stylesheet = xsltParseStylesheetFile(reinterpret_cast(stylesheetPath.c_str())); if (!stylesheet) { throw xmlpp::exception("Failed to load stylesheet"); } @@ -65,11 +65,12 @@ namespace IceSpider { throw xmlpp::exception("Failed to apply XSL transform"); } xmlOutputBufferPtr buf = xmlOutputBufferCreateIO(xmlstrmwritecallback, xmlstrmclosecallback, &strm, nullptr); - if (xmlStrcmp(stylesheet->method, BAD_CAST "html") == 0) { - htmlDocContentDumpFormatOutput(buf, result, (const char *)stylesheet->encoding, 0); + if (xmlStrcmp(stylesheet->method, reinterpret_cast("html")) == 0) { + htmlDocContentDumpFormatOutput(buf, result, reinterpret_cast(stylesheet->encoding), 0); } else { - xmlNodeDumpOutput(buf, result, result->children, 0, 0, (const char *)stylesheet->encoding); + xmlNodeDumpOutput( + buf, result, result->children, 0, 0, reinterpret_cast(stylesheet->encoding)); } xmlOutputBufferClose(buf); xmlFreeDoc(result); -- cgit v1.2.3