Commit d3a670a
committed
EmbeddedPkg/GdbStub: Fix VS2022 type conversion warnings
Fix type conversion warnings (C4244) in GdbStub that prevent it from
building with Visual Studio 2022 when the /WX flag (treat warnings as
errors) is enabled.
Instead of adding explicit casts at every assignment, change function
parameter types from UINTN to UINT32 to match the UINT32 bitfield
definitions in the IA32_DR7 structure, as suggested by maintainer
review feedback.
Changes made:
1. EmbeddedPkg/GdbStub/GdbStubInternal.h
- Update EnableDebugRegister() declaration: Address, Length, Type
parameters changed from UINTN to UINT32
- Update FindMatchingDebugRegister() declaration: Address, Length,
Type parameters changed from UINTN to UINT32
2. EmbeddedPkg/GdbStub/X64/Processor.c
- Update EnableDebugRegister() implementation to use UINT32
parameters, eliminating 12 inline casts
- Update DisableDebugRegister() to use UINT32 local variable,
eliminating 4 inline casts
- Update FindMatchingDebugRegister() implementation to use UINT32
parameters
- Update call sites to use (UINT32) casts instead of (UINTN)
- Retain necessary (UINT32)Dr7.UintN casts (2 instances)
- Update function documentation to reflect UINT32 parameter types
Rationale:
- Debug registers Dr0-Dr7 are 32-bit registers even on X64
- IA32_DR7 bitfields are defined as UINT32
- UINT32 parameter types reflect actual hardware constraints
- Results in cleaner code with fewer casts (net reduction of 14 casts)
Tested on:
- Windows 11 with VS2022 (X64 and IA32)
- Ubuntu with GCC5 (X64)
Addresses: #117371 parent 6c6d4d2 commit d3a670a
2 files changed
+22
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
676 | 676 | | |
677 | 677 | | |
678 | 678 | | |
679 | | - | |
680 | | - | |
681 | | - | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
687 | | - | |
688 | | - | |
689 | | - | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
690 | 690 | | |
691 | 691 | | |
692 | 692 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
563 | | - | |
| 563 | + | |
564 | 564 | | |
565 | | - | |
| 565 | + | |
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| |||
571 | 571 | | |
572 | 572 | | |
573 | 573 | | |
574 | | - | |
575 | | - | |
576 | | - | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
577 | 577 | | |
578 | 578 | | |
579 | 579 | | |
| |||
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
626 | | - | |
| 626 | + | |
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
639 | | - | |
| 638 | + | |
| 639 | + | |
640 | 640 | | |
641 | | - | |
| 641 | + | |
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
650 | | - | |
651 | | - | |
652 | | - | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
| |||
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
719 | | - | |
| 719 | + | |
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
749 | | - | |
| 749 | + | |
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
| |||
820 | 820 | | |
821 | 821 | | |
822 | 822 | | |
823 | | - | |
| 823 | + | |
824 | 824 | | |
825 | 825 | | |
826 | 826 | | |
| |||
896 | 896 | | |
897 | 897 | | |
898 | 898 | | |
899 | | - | |
| 899 | + | |
900 | 900 | | |
901 | 901 | | |
902 | 902 | | |
| |||
0 commit comments