-
-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve several compile warnings when comparing different int signedness #1755
Conversation
this resolve a compilation warning about comparison of expressions wih different signedness.
…r_Client_Check function this avoid a compilation warning about comparison of integer expressions of different signedness.
this avoid compilation warnings about comparison expressions of different signedness.
- resolves a compilation warning about comparison expressions of different signedness. - setupstyle() uses getcurrentstylename() to retrieve name. - correction in the message log.
- resolved a comp warning about comparison of different signedness - new function created: calculate_packed_xz(), used by const CPosition& CLevelGraph::vertex_position() and bool CLevelGraph::inside() - aditional minor resolves
…dness - resolves a warning compilation in ConvertTextureFormat(), modified to a for loop range, this avoid integers comparisions. - resolves warnings when int comparing with unsigned macro R__NUM_SUN_CASCADES, in render_phase_sun.cpp. - resolves warnings when int comparing with unsigned macro R__NUM_PARALLEL_CONTEXTS, in r2_loader.cpp - var "b_count" converted to unsigned to resolve warnings within for loops, in AnimationKeyCalculate.h - resolves warnings when for loops compare signed vs unsigned, in r__sector.cpp
…ness (2) - advances OpenXRay#713 and eliminates all warnings concerning this operation: - in R_dsgraph_structure::load() / r__dsgraph_build.cpp - var 'vcnt' converted to u32 in R_Backend_DBG.cpp - several for loops in light.cpp - several for loops in in DetailManager_CACHE.cpp - var 'filled_blocks' converted from int to i32, in SoundRender_Emitter.cpp - in CSoundRender_Core::create() / SoundRender_Core.cpp, explicit convertion of var 'sg_SourceType' to int - for loop in CollectorPacked::CollectorPacked() / xrCDB_Collector.cpp - several for loops in Frustum.cpp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I didn't checked xrAICore and xrSound yet.
The main thing to correct here is replace unsigned int
with u32
.
src/xrGame/xrServer.cpp
Outdated
@@ -866,7 +866,7 @@ void xrServer::Server_Client_Check(IClient* CL) | |||
return; | |||
}; | |||
|
|||
if (CL->process_id == GetCurrentProcessId()) | |||
if (CL->process_id == static_cast<u32>(GetCurrentProcessId())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows process_id
variable has DWORD
type and GetCurrentProcessId()
returns DWORD
too.
On Linux this variable has type pid_t
and GetCurrentProcessId() is a macro to getpid
function that returns pid_t
.
Why does it throw a warning here??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with all the changes in this commit, the warning is for comparing a signed int with an unsigned.
Edit:
Is for pid_t
:
warning: comparison of integer expressions of different signedness: ‘u32’ {aka ‘unsigned int’} and ‘__pid_t’ {aka ‘int’} [-Wsign-compare]
869 | if (CL->process_id == GetCurrentProcessId())
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this. Will it fix the warning?
if (CL->process_id == static_cast<u32>(GetCurrentProcessId())) | |
if (CL->process_id == static_cast<xrpid_t>(GetCurrentProcessId())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning persist, xrpid_t is consider an int.
How about converting process_id to int for this comparison? unsigned to signed should be safer
if (static_cast<int>(CL->process_id) == GetCurrentProcessId())
Changes requested already made. The last 2 warning regarding this (not included in the commit yet) are these:
I'm not sure the best way to resolve them, but we can do it and eliminate all. |
Also, added fixes for Images.cpp
- all `unsigned int` changed to `u32` - on SoundRender_Emitter.h - var `filled_blocks` reverted to `int` as requested. - reverted changes to `level_graph_inline.h` - proposal for `Server_Client_Check()` on `xrServer.cpp`
Requested changes made, please review 91e7e6f |
@@ -866,7 +866,7 @@ void xrServer::Server_Client_Check(IClient* CL) | |||
return; | |||
}; | |||
|
|||
if (CL->process_id == GetCurrentProcessId()) | |||
if (static_cast<int>(CL->process_id) == GetCurrentProcessId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm only unsure about this, but whatever. It can be changed later, if needed.
Thanks! |
advances #713 and eliminates several compilation warnings concerning comparison between integers of different signedness.