Skip to content

Commit 0efcf68

Browse files
committed
Fixed the following warnings:
- C:\projects\shellanything\src\shellext.cpp(632): warning C4311: 'type cast': pointer truncation from 'LPCSTR' to 'int' - C:\projects\shellanything\test\TestWin32Registry.cpp(200): warning C4477: 'sprintf' : format string '%03d' requires an argument of type 'int', but variadic argument 1 has type 'std::size_t' [C:\projects\shellanything\build\test\shellanything_unittest.vcxproj] C:\projects\shellanything\test\TestWin32Registry.cpp(200): note: consider using '%zd' in the format string - C:\projects\shellanything\test\TestWin32Registry.cpp(246): warning C4477: 'sprintf' : format string '%03d' requires an argument of type 'int', but variadic argument 1 has type 'std::size_t' [C:\projects\shellanything\build\test\shellanything_unittest.vcxproj] C:\projects\shellanything\test\TestWin32Registry.cpp(246): note: consider using '%zd' in the format string Note: the modified code does not show as warnings on VS2010.
1 parent 3adf82c commit 0efcf68

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/shellext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ HRESULT STDMETHODCALLTYPE CContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpcm
629629
//define how we should interpret lpcmi->lpVerb
630630
std::string verb;
631631
if (IS_INTRESOURCE(lpcmi->lpVerb))
632-
verb = ra::strings::ToString((int)lpcmi->lpVerb);
632+
verb = ra::strings::ToString(reinterpret_cast<int>(lpcmi->lpVerb));
633633
else
634634
verb = lpcmi->lpVerb;
635635

test/TestWin32Registry.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ namespace shellanything { namespace test
197197
std::string file_path = ra::testing::GetTestQualifiedName();
198198
static const size_t BUFFER_SIZE = 1024;
199199
char post_filename[BUFFER_SIZE];
200-
sprintf(post_filename, ".%03d.sample_file.%s", i, file_extension);
200+
sprintf(post_filename, ".%03Iu.sample_file.%s", i, file_extension);
201201
file_path.append(post_filename);
202202
bool created = ra::testing::CreateFile(file_path.c_str());
203203
ASSERT_TRUE( created ) << "Failed creating file '" << file_path << "'.";
204-
204+
205205
//get the icon matching this file's extension
206206
Win32Registry::REGISTRY_ICON icon = Win32Registry::GetFileTypeIcon(file_extension);
207207
if (icon.path.empty())
@@ -243,7 +243,7 @@ namespace shellanything { namespace test
243243

244244
//save to a file
245245
file_path = ra::testing::GetTestQualifiedName();
246-
sprintf(post_filename, ".%03d.icon_%s.bmp", i, file_extension);
246+
sprintf(post_filename, ".%03Iu.icon_%s.bmp", i, file_extension);
247247
file_path.append(post_filename);
248248
Win32Utils::CreateBmpFile(file_path.c_str(), hBitmap);
249249

0 commit comments

Comments
 (0)