Skip to content
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

chore: 消除部分编译器警告 #258

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

yixy-only
Copy link
Collaborator

@yixy-only yixy-only commented Feb 3, 2025

消除部分类型转换、安全函数等相关编译器警告

Summary by CodeRabbit

  • Refactor
    • Improved internal robustness and error handling across several modules for smoother multimedia, graphics, and text operations.
    • Enhanced type safety and secure string processing to boost overall system stability.
    • Updated calculations in image processing for more accurate pixel positioning.
    • Clarified conditional logic in keyboard input handling functions for better readability.
  • Chores
    • Adjusted build configurations to reduce compiler warnings and ensure consistent internal behavior.

@yixy-only yixy-only self-assigned this Feb 3, 2025
Copy link

coderabbitai bot commented Feb 3, 2025

Walkthrough

This pull request introduces several modifications that enhance type safety, secure string handling, and error signaling. In the button class, explicit casts and safer string copy functions are now used. Timing- and multimedia-related functions in the DLL import file return defined error codes instead of generic NULL values. Preprocessor directives are added in multiple headers and source files to suppress warnings for unsafe functions. Additionally, explicit type casts have been added in graphics transformation calls, safer string formatting was implemented in the font module, and improvements were made in image processing calculations. Core functionality remains unchanged.

Changes

File(s) Change Summary
include/ege/button.h Explicit cast in updatesidewidth; uses strcpy_s for _face, _caption, and _font initialization for MSVC ≥ 1400.
src/ege_dllimport.cpp Timing and MCI functions now return specific error codes (MMSYSERR_NOTSUPPORTED, MMSYSERR_ERROR) instead of NULL.
src/ege_head.h,
src/egecontrolbase.cpp
Added #ifndef _CRT_SECURE_NO_WARNINGS and corresponding define to suppress warnings on unsafe C runtime functions.
src/egegapi.cpp Added explicit casts to Gdiplus::REAL in the TranslateTransform call within setviewport.
src/font.cpp Replaced vsprintf/vswprintf with safer variants (vsprintf_s/vswprintf_s) and adjusted the buffer start offset.
src/image.cpp Updated calculations in putimage_rotatetransparent to use round for dimensions and coordinates; added explicit casts for pixel manipulation.
src/time.cpp Explicitly casts delay calculation to long before calling ege_sleep in the delay_ms function.
src/graphics.cpp Removed unused variable declaration in setinitmode.
src/keyboard.cpp Improved clarity of conditional logic in peekkey and getchEx functions.

Poem

I’m a rabbit coding through the night,
Hopping over bugs with precision and might.
Casting values and copying strings secure,
With error codes that are clear and sure.
In every line, a safe leap in the flow—
A bunny’s happy code begins to glow! 🐇

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cfa394f and e0178f5.

📒 Files selected for processing (12)
  • include/ege/button.h (4 hunks)
  • include/ege/egecontrolbase.h (1 hunks)
  • include/ege/label.h (2 hunks)
  • src/ege_dllimport.cpp (4 hunks)
  • src/ege_head.h (1 hunks)
  • src/egecontrolbase.cpp (1 hunks)
  • src/egegapi.cpp (2 hunks)
  • src/font.cpp (7 hunks)
  • src/graphics.cpp (1 hunks)
  • src/image.cpp (7 hunks)
  • src/keyboard.cpp (2 hunks)
  • src/time.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/ege_head.h
  • include/ege/button.h
  • src/time.cpp
  • src/image.cpp
  • src/egegapi.cpp
🧰 Additional context used
🪛 Cppcheck (2.10-2)
src/egecontrolbase.cpp

[performance] 16-16: Variable 'm_target' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

src/font.cpp

[error] 344-344: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 345-345: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 346-346: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 347-347: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 348-348: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 349-349: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 350-350: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 351-351: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 364-364: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 365-365: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 366-366: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 367-367: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 368-368: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 369-369: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: TESTING
🔇 Additional comments (10)
include/ege/label.h (1)

28-32: LGTM! Safer string handling with strcpy_s.

The changes improve safety by using strcpy_s with buffer size checks on MSVC, while maintaining compatibility with other compilers. This effectively eliminates compiler warnings about unsafe string functions.

Also applies to: 38-42, 58-62

src/keyboard.cpp (1)

31-32: LGTM! Improved operator precedence clarity.

The added parentheses make the logical operator precedence explicit, eliminating potential compiler warnings and improving code readability.

Also applies to: 148-149

include/ege/egecontrolbase.h (1)

48-49: LGTM! Improved initialization order.

The change ensures proper initialization order by moving the egecontrolbase_preinit_obj instantiation after the parent class initialization, eliminating potential compiler warnings.

src/ege_dllimport.cpp (1)

187-187: LGTM! Improved error handling with specific error codes.

The changes replace generic NULL returns with meaningful error codes:

  • MMSYSERR_NOTSUPPORTED for timing functions
  • MMSYSERR_ERROR for MCI command function

This improves error handling and eliminates compiler warnings about returning NULL for MMRESULT/MCIERROR types.

Also applies to: 195-195, 204-204, 213-213, 222-222

src/egecontrolbase.cpp (1)

14-16: LGTM!

The addition of #pragma warning(disable : 4786) within the MSVC-specific block is appropriate for handling the identifier length warning.

🧰 Tools
🪛 Cppcheck (2.10-2)

[performance] 16-16: Variable 'm_target' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

src/font.cpp (4)

121-121: LGTM!

Removed redundant call to DrawTextW for height calculation, as the height is already calculated in the subsequent code.


187-192: LGTM!

The changes improve string handling safety by:

  1. Using vsprintf_s and vswprintf_s for MSVC >= 1400
  2. Properly calculating buffer sizes
  3. Maintaining compatibility with other compilers

Also applies to: 206-211, 224-229, 242-247


344-351: LGTM!

The buffer handling in ege_xyprintf has been improved by:

  1. Calculating the correct buffer length using sizeof(pg->g_t_buff) / sizeof(pg->g_t_buff[0])
  2. Writing to the middle of the buffer to avoid overlap
  3. Using the correct buffer size for vsprintf_s
🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 344-344: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 345-345: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 346-346: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 347-347: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 348-348: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 349-349: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 350-350: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 351-351: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


364-369: LGTM!

The changes improve string handling safety in ege_xyprintf (wide char version) by:

  1. Using vswprintf_s for MSVC >= 1400
  2. Properly calculating buffer size for wide characters
  3. Maintaining compatibility with other compilers
🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 364-364: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 365-365: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 366-366: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 367-367: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 368-368: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 369-369: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)

src/graphics.cpp (1)

1000-1001: LGTM!

Removed unused variable declaration struct _graph_setting* pg = &graph_setting;, which helps eliminate compiler warnings.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/egecontrolbase.cpp (1)

14-16: Suppress Compiler Warnings Directive Added

The new preprocessor block:

#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif

has been introduced to suppress warnings related to potentially unsafe C-runtime functions. This aligns with the similar directive added in ege_head.h and directly addresses the compiler warnings targeted in the PR objective.

Please ensure that this suppression is an intentional decision rather than a permanent workaround. It may be beneficial to audit the usage of functions that trigger these warnings to confirm that they do not introduce security or safety issues in the long run.

🧰 Tools
🪛 Cppcheck (2.10-2)

[performance] 16-16: Variable 'm_target' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5978ca1 and 76c15f5.

📒 Files selected for processing (8)
  • include/ege/button.h (4 hunks)
  • src/ege_dllimport.cpp (4 hunks)
  • src/ege_head.h (1 hunks)
  • src/egecontrolbase.cpp (1 hunks)
  • src/egegapi.cpp (2 hunks)
  • src/font.cpp (6 hunks)
  • src/image.cpp (1 hunks)
  • src/time.cpp (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/ege_head.h
  • src/egegapi.cpp
🧰 Additional context used
🪛 Cppcheck (2.10-2)
src/font.cpp

[error] 344-344: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 345-345: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 346-346: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 347-347: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 348-348: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 349-349: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 350-350: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 351-351: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 364-364: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 365-365: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 366-366: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 367-367: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 368-368: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 369-369: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)

src/egecontrolbase.cpp

[performance] 16-16: Variable 'm_target' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

🔇 Additional comments (17)
src/time.cpp (1)

92-92: LGTM! Improved type safety with explicit cast.

The explicit cast to long for the sleep duration eliminates potential precision loss warnings from implicit conversion.

include/ege/button.h (4)

116-121: LGTM! Using safer string handling function.

Using strcpy_s when available improves buffer overflow protection.


246-251: LGTM! Using safer string handling function.

Using strcpy_s when available improves buffer overflow protection.


262-267: LGTM! Using safer string handling function.

Using strcpy_s when available improves buffer overflow protection.


318-318: LGTM! Improved type safety with explicit cast.

The explicit cast to int prevents potential precision loss warnings from the floating-point calculation.

src/ege_dllimport.cpp (5)

187-187: LGTM! Improved error handling with specific error code.

Using MMSYSERR_NOTSUPPORTED instead of NULL provides a more meaningful error code.


195-195: LGTM! Improved error handling with specific error code.

Using MMSYSERR_NOTSUPPORTED instead of NULL provides a more meaningful error code.


204-204: LGTM! Improved error handling with specific error code.

Using MMSYSERR_NOTSUPPORTED instead of NULL provides a more meaningful error code.


213-213: LGTM! Improved error handling with specific error code.

Using MMSYSERR_NOTSUPPORTED instead of NULL provides a more meaningful error code.


222-222: LGTM! Improved error handling with specific error code.

Using MMSYSERR_ERROR instead of NULL provides a more meaningful error code.

src/font.cpp (6)

187-192: LGTM! Using safer string formatting function.

Using vsprintf_s with proper buffer size calculation improves buffer overflow protection.


206-211: LGTM! Using safer string formatting function.

Using vswprintf_s with proper buffer size calculation improves buffer overflow protection.


224-229: LGTM! Using safer string formatting function.

Using vsprintf_s with proper buffer size calculation improves buffer overflow protection.


242-247: LGTM! Using safer string formatting function.

Using vswprintf_s with proper buffer size calculation improves buffer overflow protection.


344-351: LGTM! Improved buffer management.

Writing to the middle of the buffer helps avoid potential overlap issues when the buffer is used concurrently.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 344-344: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 345-345: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 346-346: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 347-347: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 348-348: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 349-349: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 350-350: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 351-351: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


364-369: LGTM! Using safer string formatting function.

Using vswprintf_s with proper buffer size calculation improves buffer overflow protection.

🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 364-364: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 365-365: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 366-366: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 367-367: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 368-368: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 369-369: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)

src/image.cpp (1)

3280-3284: LGTM! Proper use of unsigned integer suffixes.

The addition of 'U' suffixes to hexadecimal constants is correct and helps eliminate potential compiler warnings about integer constant size/sign conversions. The values remain unchanged:

  • 0x00FF0000U for red mask
  • 0x0000FF00U for green mask
  • 0x000000FFU for blue mask
  • 0xFF000000U for alpha mask
  • 0x73524742U for sRGB color space

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/font.cpp (5)

187-192: LGTM! Consider adding buffer size check for non-MSVC builds.

The use of vsprintf_s with proper buffer size calculation is a good improvement for MSVC builds. However, the non-MSVC path still uses unsafe vsprintf.

Consider adding a manual buffer size check for non-MSVC builds:

#if defined(_MSC_VER) && (_MSC_VER >= 1400)
    size_t bufferCount = sizeof(pg->g_t_buff);
    vsprintf_s(buff, bufferCount, format, v);
#else
-   vsprintf(buff, format, v);
+   size_t bufferCount = sizeof(pg->g_t_buff);
+   if (vsnprintf(buff, bufferCount, format, v) >= bufferCount) {
+       // Handle buffer overflow
+   }
#endif

206-211: LGTM! Consider adding buffer size check for non-MSVC builds.

The use of vswprintf_s with proper buffer size calculation is a good improvement for MSVC builds. However, the non-MSVC path still uses unsafe vswprintf.

Consider adding a manual buffer size check for non-MSVC builds:

#if defined(_MSC_VER) && (_MSC_VER >= 1400)
    size_t bufferCount = sizeof(pg->g_t_buff) / sizeof(wchar_t);
    vswprintf_s(buff, bufferCount, format, v);
#else
-   vswprintf(buff, format, v);
+   size_t bufferCount = sizeof(pg->g_t_buff) / sizeof(wchar_t);
+   if (vswprintf(buff, bufferCount, format, v) >= bufferCount) {
+       // Handle buffer overflow
+   }
#endif

224-229: LGTM! Consider adding buffer size check for non-MSVC builds.

The use of vsprintf_s with proper buffer size calculation is a good improvement for MSVC builds. However, the non-MSVC path still uses unsafe vsprintf.

Consider adding a manual buffer size check for non-MSVC builds:

#if defined(_MSC_VER) && (_MSC_VER >= 1400)
    size_t bufferCount = sizeof(pg->g_t_buff);
    vsprintf_s(buff, bufferCount, format, v);
#else
-   vsprintf(buff, format, v);
+   size_t bufferCount = sizeof(pg->g_t_buff);
+   if (vsnprintf(buff, bufferCount, format, v) >= bufferCount) {
+       // Handle buffer overflow
+   }
#endif

242-247: LGTM! Consider adding buffer size check for non-MSVC builds.

The use of vswprintf_s with proper buffer size calculation is a good improvement for MSVC builds. However, the non-MSVC path still uses unsafe vswprintf.

Consider adding a manual buffer size check for non-MSVC builds:

#if defined(_MSC_VER) && (_MSC_VER >= 1400)
    size_t bufferCount = sizeof(pg->g_t_buff) / sizeof(wchar_t);
    vswprintf_s(buff, bufferCount, format, v);
#else
-   vswprintf(buff, format, v);
+   size_t bufferCount = sizeof(pg->g_t_buff) / sizeof(wchar_t);
+   if (vswprintf(buff, bufferCount, format, v) >= bufferCount) {
+       // Handle buffer overflow
+   }
#endif

344-351: LGTM! Consider adding buffer size check for non-MSVC builds.

The buffer length calculation and writing from the middle of the buffer is a good approach to avoid overlap. The use of vsprintf_s with proper buffer size calculation is also a good improvement for MSVC builds. However, the non-MSVC path still uses unsafe vsprintf.

Consider adding a manual buffer size check for non-MSVC builds:

const int bufferLength = sizeof(pg->g_t_buff) / sizeof(pg->g_t_buff[0]);
char* buff = (char*)(pg->g_t_buff + bufferLength / 2);
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
    size_t bufferCount = sizeof(pg->g_t_buff) / 2;
    vsprintf_s(buff, bufferCount, format, v);
#else
-   vsprintf(buff, format, v);
+   size_t bufferCount = sizeof(pg->g_t_buff) / 2;
+   if (vsnprintf(buff, bufferCount, format, v) >= bufferCount) {
+       // Handle buffer overflow
+   }
#endif
🧰 Tools
🪛 Cppcheck (2.10-2)

[error] 344-344: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 345-345: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 346-346: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 347-347: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 348-348: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 349-349: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 350-350: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 351-351: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76c15f5 and cfa394f.

📒 Files selected for processing (8)
  • include/ege/button.h (4 hunks)
  • src/ege_dllimport.cpp (4 hunks)
  • src/ege_head.h (1 hunks)
  • src/egecontrolbase.cpp (1 hunks)
  • src/egegapi.cpp (2 hunks)
  • src/font.cpp (6 hunks)
  • src/image.cpp (3 hunks)
  • src/time.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/ege_head.h
  • src/time.cpp
  • include/ege/button.h
  • src/ege_dllimport.cpp
  • src/egegapi.cpp
🧰 Additional context used
🪛 Cppcheck (2.10-2)
src/font.cpp

[error] 344-344: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 345-345: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 346-346: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 347-347: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 348-348: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 349-349: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 350-350: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 351-351: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 364-364: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 365-365: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 366-366: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 367-367: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 368-368: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)


[error] 369-369: Signed integer overflow for expression '0xFF<<24'.

(integerOverflow)

src/egecontrolbase.cpp

[performance] 16-16: Variable 'm_target' is assigned in constructor body. Consider performing initialization in initialization list.

(useInitializationList)

🔇 Additional comments (4)
src/image.cpp (4)

713-714: Improve precision by using round() for zoomed dimensions.

The change from implicit conversion to explicit rounding using round() improves precision and eliminates potential compiler warnings about floating-point to integer conversions.


715-716: Improve precision by using round() for center coordinates.

Similar to the zoomed dimensions, using round() for center coordinates provides more accurate positioning and eliminates potential compiler warnings.


734-737: Improve type safety by using explicit integer casts.

The changes add explicit integer casts using (int) for source coordinates in putpixel_savealpha calls, which improves type safety and eliminates compiler warnings about floating-point to integer conversions.


3280-3284: Add explicit unsigned suffix for color masks.

The addition of U suffix to hexadecimal color mask values improves type safety by explicitly marking them as unsigned integers, which eliminates potential compiler warnings about signed/unsigned mismatches.

@yixy-only yixy-only merged commit d1aebb1 into wysaid:master Feb 4, 2025
2 checks passed
@yixy-only yixy-only deleted the chore_warnings branch February 4, 2025 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant