summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.lib2
-rw-r--r--src/3rdparty/squirrel/squirrel/sqvm.cpp2
-rw-r--r--src/fileio.cpp2
-rw-r--r--src/gfx.cpp4
-rw-r--r--src/industry_gui.cpp2
-rw-r--r--src/misc/blob.hpp4
-rw-r--r--src/network/network_server.cpp2
-rw-r--r--src/newgrf.cpp10
-rw-r--r--src/newgrf_engine.cpp2
-rw-r--r--src/newgrf_station.cpp2
-rw-r--r--src/vehicle.cpp4
-rw-r--r--src/vehicle_gui.cpp2
12 files changed, 18 insertions, 20 deletions
diff --git a/config.lib b/config.lib
index 64d84654f..9ff14ed2a 100644
--- a/config.lib
+++ b/config.lib
@@ -1103,7 +1103,7 @@ make_cflags_and_ldflags() {
if [ $cc_version -ge 29 ]; then
CFLAGS="$CFLAGS -Wall -Wno-multichar -Wsign-compare -Wundef"
CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith"
- CFLAGS="$CFLAGS -Wno-uninitialized"
+ CFLAGS="$CFLAGS -Wno-uninitialized -Wcast-qual"
CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes"
fi
diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp
index 0cb66e9c1..bed94bf6e 100644
--- a/src/3rdparty/squirrel/squirrel/sqvm.cpp
+++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp
@@ -440,7 +440,7 @@ bool SQVM::DerefInc(SQInteger op,SQObjectPtr &target, SQObjectPtr &self, SQObjec
#define arg0 (_i_._arg0)
#define arg1 (_i_._arg1)
-#define sarg1 (*((SQInt32 *)&_i_._arg1))
+#define sarg1 (*(const_cast<SQInt32 *>(&_i_._arg1)))
#define arg2 (_i_._arg2)
#define arg3 (_i_._arg3)
#define sarg3 ((SQInteger)*((signed char *)&_i_._arg3))
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 154bd6c9e..7abf732fb 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -807,7 +807,7 @@ void ChangeWorkingDirectory(const char *exe)
if (app_bundle != NULL) app_bundle[0] = '\0';
#endif /* WITH_COCOA */
- char *s = (char*)strrchr(exe, PATHSEPCHAR);
+ char *s = const_cast<char *>(strrchr(exe, PATHSEPCHAR));
if (s != NULL) {
*s = '\0';
#if defined(__DJGPP__)
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 775cd94a5..1648e30b3 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -340,7 +340,7 @@ static int TruncateString(char *str, int maxw)
ddd_w = ddd = GetCharacterWidth(size, '.') * 3;
- for (ddd_pos = str; (c = Utf8Consume((const char **)&str)) != '\0'; ) {
+ for (ddd_pos = str; (c = Utf8Consume(const_cast<const char **>(&str))) != '\0'; ) {
if (IsPrintable(c)) {
w += GetCharacterWidth(size, c);
@@ -577,7 +577,7 @@ uint32 FormatStringLinebreaks(char *str, int maxw)
int w = 0;
for (;;) {
- WChar c = Utf8Consume((const char **)&str);
+ WChar c = Utf8Consume(const_cast<const char **>(&str));
/* whitespace is where we will insert the line-break */
if (IsWhitespace(c)) last_space = str;
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 526b89421..f71eabce6 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -954,7 +954,7 @@ public:
if (i->produced_cargo[j] == CT_INVALID) continue;
SetDParam(p++, i->produced_cargo[j]);
SetDParam(p++, i->last_month_production[j]);
- SetDParam(p++, GetCargoSuffix(j + 3, CST_DIR, (Industry*)i, i->type, indsp));
+ SetDParam(p++, GetCargoSuffix(j + 3, CST_DIR, const_cast<Industry *>(i), i->type, indsp));
}
/* Transported productions */
diff --git a/src/misc/blob.hpp b/src/misc/blob.hpp
index 56e10a7cf..cdda12bd3 100644
--- a/src/misc/blob.hpp
+++ b/src/misc/blob.hpp
@@ -82,7 +82,7 @@ public:
{
assert(pHdr_1 != NULL);
ptr_u.m_pHdr_1 = pHdr_1;
- *(CHdr**)&pHdr_1 = NULL;
+ *const_cast<CHdr**>(&pHdr_1) = NULL;
}
/** destructor */
@@ -330,7 +330,7 @@ public:
struct OnTransfer {
typename Tbase_::CHdr *m_pHdr_1;
- OnTransfer(const OnTransfer& src) : m_pHdr_1(src.m_pHdr_1) {assert(src.m_pHdr_1 != NULL); *(typename Tbase_::CHdr**)&src.m_pHdr_1 = NULL;}
+ OnTransfer(const OnTransfer& src) : m_pHdr_1(src.m_pHdr_1) {assert(src.m_pHdr_1 != NULL); *const_cast<typename Tbase_::CHdr**>(&src.m_pHdr_1) = NULL;}
OnTransfer(CBlobT& src) : m_pHdr_1(src.ptr_u.m_pHdr_1) {src.InitEmpty();}
~OnTransfer() {assert(m_pHdr_1 == NULL);}
};
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 2ccd5c625..07c638b09 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1793,7 +1793,7 @@ void NetworkServerBanIP(const char *banip)
/* There can be multiple clients with the same IP, kick them all */
FOR_ALL_CLIENT_INFOS(ci) {
- if (ci->client_address.IsInNetmask((char*)banip)) {
+ if (ci->client_address.IsInNetmask(const_cast<char *>(banip))) {
NetworkServerKickClient(ci->client_id);
}
}
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index a510f2daa..2171a4850 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -1158,11 +1158,9 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, byte
MapSpriteMappingRecolour(&dts->ground);
while (buf < *bufp + len) {
- DrawTileSeqStruct *dtss;
-
/* no relative bounding box support */
- dts->seq = ReallocT((DrawTileSeqStruct*)dts->seq, ++seq_count);
- dtss = (DrawTileSeqStruct*) &dts->seq[seq_count - 1];
+ dts->seq = ReallocT(const_cast<DrawTileSeqStruct *>(dts->seq), ++seq_count);
+ DrawTileSeqStruct *dtss = const_cast<DrawTileSeqStruct *>(&dts->seq[seq_count - 1]);
dtss->delta_x = grf_load_byte(&buf);
if ((byte) dtss->delta_x == 0x80) break;
@@ -2907,7 +2905,7 @@ static void NewSpriteGroup(byte *buf, size_t len)
group->dts->seq = CallocT<DrawTileSeqStruct>(num_sprites + 1);
for (i = 0; i < num_sprites; i++) {
- DrawTileSeqStruct *seq = (DrawTileSeqStruct*)&group->dts->seq[i];
+ DrawTileSeqStruct *seq = const_cast<DrawTileSeqStruct*>(&group->dts->seq[i]);
seq->image.sprite = grf_load_word(&buf);
seq->image.pal = grf_load_word(&buf);
@@ -2935,7 +2933,7 @@ static void NewSpriteGroup(byte *buf, size_t len)
}
/* Set the terminator value. */
- ((DrawTileSeqStruct*)group->dts->seq)[i].delta_x = (int8)0x80;
+ const_cast<DrawTileSeqStruct *>(group->dts->seq)[i].delta_x = (int8)0x80;
break;
}
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 60529f09c..a85d2f376 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -416,7 +416,7 @@ static void VehicleSetTriggers(const ResolverObject *object, int triggers)
* innocent looking function pointer cast... Currently I cannot see a
* way of avoiding this without removing consts deep within gui code.
*/
- Vehicle *v = (Vehicle*)GRV(object);
+ Vehicle *v = const_cast<Vehicle *>(GRV(object));
/* This function must only be called when processing triggers -- any
* other time is an error. */
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index eb2598c27..f3d4d4b92 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -335,7 +335,7 @@ static uint32 StationGetTriggers(const ResolverObject *object)
static void StationSetTriggers(const ResolverObject *object, int triggers)
{
- Station *st = (Station*)object->u.station.st;
+ Station *st = const_cast<Station *>(object->u.station.st);
assert(st != NULL);
st->waiting_triggers = triggers;
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 73887577b..5b54c5b2a 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1396,7 +1396,7 @@ static SpriteID GetEngineColourMap(EngineID engine_type, CompanyID company, Engi
* map else it's returned as-is. */
if (!HasBit(callback, 14)) {
/* Update cache */
- if (v != NULL) ((Vehicle*)v)->colourmap = map;
+ if (v != NULL) const_cast<Vehicle *>(v)->colourmap = map;
return map;
}
}
@@ -1412,7 +1412,7 @@ static SpriteID GetEngineColourMap(EngineID engine_type, CompanyID company, Engi
if (twocc) map += livery->colour2 * 16;
/* Update cache */
- if (v != NULL) ((Vehicle*)v)->colourmap = map;
+ if (v != NULL) const_cast<Vehicle *>(v)->colourmap = map;
return map;
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index e1cc4aef0..57bb893b1 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -144,7 +144,7 @@ static RefitList *BuildRefitList(const Vehicle *v)
uint max_lines = 256;
RefitOption *refit = CallocT<RefitOption>(max_lines);
RefitList *list = CallocT<RefitList>(1);
- Vehicle *u = (Vehicle*)v;
+ Vehicle *u = const_cast<Vehicle *>(v);
uint num_lines = 0;
uint i;