Skip to content

Fix compilation warnings#213

Open
TotalCaesar659 wants to merge 2 commits intogrumpycoders:mainfrom
TotalCaesar659:warnings
Open

Fix compilation warnings#213
TotalCaesar659 wants to merge 2 commits intogrumpycoders:mainfrom
TotalCaesar659:warnings

Conversation

@TotalCaesar659
Copy link
Copy Markdown
Contributor

src/core/misc.cc: In function ‘bool CheckCdrom()’:
src/core/misc.cc:311:44: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘const char8_t*’ [-Wformat=]
  311 |         sprintf(mcd1path, "memcards/games/%s-%02d.mcd",
      |                                           ~^
      |                                            |
      |                                            char*
      |                                           %hhn
  312 |                 PCSX::g_emulator->settings.get<PCSX::Emulator::SettingPsxExe>().string().c_str(), 1);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                               |
      |                                                                                               const char8_t*
src/core/misc.cc:313:44: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘const char8_t*’ [-Wformat=]
  313 |         sprintf(mcd2path, "memcards/games/%s-%02d.mcd",
      |                                           ~^
      |                                            |
      |                                            char*
      |                                           %hhn
  314 |                 PCSX::g_emulator->settings.get<PCSX::Emulator::SettingPsxExe>().string().c_str(), 2);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                               |
      |                                                                                               const char8_t*
src/core/misc.cc: In function ‘void LoadLibPS()’:
src/core/misc.cc:356:20: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘const char8_t*’ [-Wformat=]
  356 |     sprintf(buf, "%s/libps.exe",
      |                   ~^
      |                    |
      |                    char*
      |                   %hhn
  357 |             PCSX::g_emulator->settings.get<PCSX::Emulator::SettingBios>().value.parent_path().u8string().c_str());
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                                                                               |
      |                                                                                                               const char8_t*
...
src/core/cdriso.cc: In member function ‘int PCSX::CDRiso::LoadSBI(const char*)’:
src/core/cdriso.cc:1295:28: warning: format ‘%s’ expects argument of type ‘char*’, but argument 3 has type ‘const char8_t*’ [-Wformat=]
 1295 |         sprintf(sbifile, "%s%s", PCSX::g_emulator->settings.get<Emulator::SettingPpfDir>().string().c_str(), buffer);
      |                           ~^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                            |                                                                             |
      |                            char*                                                                         const char8_t*
      |                           %hhn

@nicolasnoble
Copy link
Copy Markdown
Member

So unfortunately, hhn is a POSIX specific extension, and most likely won't work properly in a cross platform setting.

At this point, it might make more sense to start using fmt::format, like I've done in other locations of the code:

std::string label = fmt::format("<{:08x}> {:30} {}", node.get_section_offset(), to_string(node.tag), name);

https://fmt.dev/latest/index.html

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2020

Codecov Report

Merging #213 into master will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #213      +/-   ##
=========================================
- Coverage    1.61%   1.61%   -0.01%     
=========================================
  Files         134     134              
  Lines       35564   35568       +4     
=========================================
  Hits          574     574              
- Misses      34990   34994       +4     
Impacted Files Coverage Δ
src/core/cdriso.cc 0.00% <0.00%> (ø)
src/core/misc.cc 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3a4c46...aa6795a. Read the comment docs.

@TotalCaesar659
Copy link
Copy Markdown
Contributor Author

@nicolasnoble I tried to understand this fmt, but please, help))

@nicolasnoble
Copy link
Copy Markdown
Member

Right, well, moving over to fmt::format isn't a small undertaking :-) A lot of various algorithms and memory management routines around these functions need to change drastically. This is something that can be done at a later time. There's still much to be done :)

@TotalCaesar659
Copy link
Copy Markdown
Contributor Author

Yeah, we can save that for later.

@nicolasnoble nicolasnoble reopened this Jun 20, 2020
@nicolasnoble nicolasnoble changed the base branch from master to main June 20, 2020 04:21
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.

2 participants