Skip to content

Commit

Permalink
Cut down on some strlens for xdk
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Sep 2, 2023
1 parent c2b8188 commit bc91eb6
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions frontend/drivers/platform_xdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -918,18 +918,17 @@ static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
#endif
char szSourceDevice[48] = {0};
char szDestinationDrive[16] = {0};

snprintf(szSourceDevice, sizeof(szSourceDevice),
size_t sz_src_device_len = snprintf(szSourceDevice, sizeof(szSourceDevice),
"\\Device\\%s", szDevice);
snprintf(szDestinationDrive, sizeof(szDestinationDrive),
size_t sz_dest_len = snprintf(szDestinationDrive, sizeof(szDestinationDrive),
"\\??\\%s", szDrive);

DeviceName.Length = strlen(szSourceDevice);
DeviceName.MaximumLength = strlen(szSourceDevice) + 1;
DeviceName.Length = sz_src_device_len;
DeviceName.MaximumLength = sz_src_device_len + 1;
DeviceName.Buffer = szSourceDevice;

LinkName.Length = strlen(szDestinationDrive);
LinkName.MaximumLength = strlen(szDestinationDrive) + 1;
LinkName.Length = sz_dest_len;
LinkName.MaximumLength = sz_dest_len + 1;
LinkName.Buffer = szDestinationDrive;

IoCreateSymbolicLink(&LinkName, &DeviceName);
Expand All @@ -947,12 +946,11 @@ static HRESULT xbox_io_unmount(char *szDrive)
{
STRING LinkName;
char szDestinationDrive[16] = {0};

snprintf(szDestinationDrive, sizeof(szDestinationDrive),
size_t sz_dest_len = snprintf(szDestinationDrive, sizeof(szDestinationDrive),
"\\??\\%s", szDrive);

LinkName.Length = strlen(szDestinationDrive);
LinkName.MaximumLength = strlen(szDestinationDrive) + 1;
LinkName.Length = sz_dest_len;
LinkName.MaximumLength = sz_dest_len + 1;
LinkName.Buffer = szDestinationDrive;

IoDeleteSymbolicLink(&LinkName);
Expand All @@ -976,8 +974,7 @@ HRESULT ObCreateSymbolicLink(PSTRING SymbolicLinkName, PSTRING DeviceName);
static HRESULT xbox_io_mount(const char* szDrive, char* szDevice)
{
STRING DeviceName, LinkName;
char szDestinationDrive[PATH_MAX_LENGTH];

char szDestinationDrive[16];
snprintf(szDestinationDrive, sizeof(szDestinationDrive),
"\\??\\%s", szDrive);
RtlInitAnsiString(&DeviceName, szDevice);
Expand Down

0 comments on commit bc91eb6

Please sign in to comment.