Skip to content

Commit

Permalink
Use static_cast when performing type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
eschan145 committed Jan 25, 2025
1 parent e9027b5 commit dfe3c48
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@ DK_API bool taskkill(DWORD identifier, KillMethod method) {

if (process) {
// Bam, terminated!
TerminateProcess(process, -1);
TerminateProcess(process, static_cast<UINT>(-1));
// -1 is the exit code for the process - in this case,
// indicating internal failure.
CloseHandle(process);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ const char* get_selected(HWND listbox) {
Get the selected item in a listbox.
*/

int index = SendMessage(listbox, LB_GETCURSEL, 0, 0);
int index = static_cast<UINT>(SendMessage(listbox, LB_GETCURSEL, 0, 0));
if (index == LB_ERR) {
// Unable to get listbox contents for some reason (no selection?)
return "";
}

// Needed to specify memory allocation
int length = SendMessage(listbox, LB_GETTEXTLEN, index, 0);
int length = static_cast<UINT>(SendMessage(listbox, LB_GETTEXTLEN, index, 0));

// Create a character buffer to output the selected item
char* buffer = new char[length + 1];
Expand Down
2 changes: 1 addition & 1 deletion src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ int ErrorBuffer::overflow(int c) {
original_buffer->sputc('1');
original_buffer->sputc('m');

original_buffer->sputc(c);
original_buffer->sputc(static_cast<_Elem>(c));

original_buffer->sputc('\033');
original_buffer->sputc('[');
Expand Down

0 comments on commit dfe3c48

Please sign in to comment.