Building dethrace with clang/apple-clang emits -Wabsolute-value warnings in car.c.
These are about taking the absolute value of an unsigned number, which is a no-op.
Should this warning be silinced (through a pragma)?
Or should the argument to abs first be casted to a signed int?
[143/210] Building C object src/DETHRACE/CMakeFiles/dethrace_obj.dir/common/car.c.o
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4619:13: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
if (abs(GetTotalTime() - next_incident_time) > 2500) {
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4619:13: note: remove the call to 'abs' since unsigned values cannot be negative
if (abs(GetTotalTime() - next_incident_time) > 2500) {
^~~
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4645:13: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
if (abs(GetTotalTime() - next_incident_time) > 2500) {
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4645:13: note: remove the call to 'abs' since unsigned values cannot be negative
if (abs(GetTotalTime() - next_incident_time) > 2500) {
^~~
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4656:13: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
if (abs(GetTotalTime() - next_incident_time) > 2500) {
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4656:13: note: remove the call to 'abs' since unsigned values cannot be negative
if (abs(GetTotalTime() - next_incident_time) > 2500) {
^~~
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4706:13: warning: taking the absolute value of unsigned type 'tU32' (aka 'unsigned int') has no effect [-Wabsolute-value]
if (abs(*next_incident_time) > 2500) {
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4706:13: note: remove the call to 'abs' since unsigned values cannot be negative
if (abs(*next_incident_time) > 2500) {
^~~
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4710:44: warning: taking the absolute value of unsigned type 'tU32' (aka 'unsigned int') has no effect [-Wabsolute-value]
for (test = 0; GetNextIncident(abs(t), &type2, &severity2, &info2, &next_incident_time2) && test <= 10 && abs(next_incident_time2) <= 3500; test++) {
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4710:44: note: remove the call to 'abs' since unsigned values cannot be negative
for (test = 0; GetNextIncident(abs(t), &type2, &severity2, &info2, &next_incident_time2) && test <= 10 && abs(next_incident_time2) <= 3500; test++) {
^~~
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4710:119: warning: taking the absolute value of unsigned type 'tU32' (aka 'unsigned int') has no effect [-Wabsolute-value]
for (test = 0; GetNextIncident(abs(t), &type2, &severity2, &info2, &next_incident_time2) && test <= 10 && abs(next_incident_time2) <= 3500; test++) {
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4710:119: note: remove the call to 'abs' since unsigned values cannot be negative
for (test = 0; GetNextIncident(abs(t), &type2, &severity2, &info2, &next_incident_time2) && test <= 10 && abs(next_incident_time2) <= 3500; test++) {
^~~
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4719:17: warning: taking the absolute value of unsigned type 'tU32' (aka 'unsigned int') has no effect [-Wabsolute-value]
if (abs(*next_incident_time) > 2500) {
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4719:17: note: remove the call to 'abs' since unsigned values cannot be negative
if (abs(*next_incident_time) > 2500) {
^~~
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4727:65: warning: taking the absolute value of unsigned type 'tU32' (aka 'unsigned int') has no effect [-Wabsolute-value]
ScanCarsPositions(c, &c->pos, 100000.f, -1, abs(*next_incident_time), &pos, &t);
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4727:65: note: remove the call to 'abs' since unsigned values cannot be negative
ScanCarsPositions(c, &c->pos, 100000.f, -1, abs(*next_incident_time), &pos, &t);
^~~
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4861:52: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
ScanCarsPositions(c, &tv, 10000.f, abs(t2 - GetTotalTime()), time_step, &tv2, &time);
^
/home/maarten/projects/dethrace/src/DETHRACE/common/car.c:4861:52: note: remove the call to 'abs' since unsigned values cannot be negative
ScanCarsPositions(c, &tv, 10000.f, abs(t2 - GetTotalTime()), time_step, &tv2, &time);
^~~
9 warnings generated.
The warnings are all in action replay camera functions.
Building dethrace with clang/apple-clang emits
-Wabsolute-value
warnings in car.c. These are about taking the absolute value of an unsigned number, which is a no-op.Should this warning be silinced (through a pragma)? Or should the argument to
abs
first be casted to a signed int?The warnings are all in action replay camera functions.