Janitorial: Get rid of strncpy/strncpyW.
This commit is contained in:
parent
4a8ce2ae41
commit
a667d536b9
|
@ -72,7 +72,7 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
|
||||||
|
|
||||||
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
|
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
|
||||||
ACMFORMATDETAILSA afd;
|
ACMFORMATDETAILSA afd;
|
||||||
unsigned int i, idx;
|
unsigned int i, len;
|
||||||
MMRESULT mmr;
|
MMRESULT mmr;
|
||||||
char buffer[ACMFORMATDETAILS_FORMAT_CHARS+16];
|
char buffer[ACMFORMATDETAILS_FORMAT_CHARS+16];
|
||||||
|
|
||||||
|
@ -88,10 +88,9 @@ static BOOL CALLBACK MSACM_FillFormatTagsCB(HACMDRIVERID hadid,
|
||||||
afd.dwFormatIndex = i;
|
afd.dwFormatIndex = i;
|
||||||
mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
|
mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
|
||||||
if (mmr == MMSYSERR_NOERROR) {
|
if (mmr == MMSYSERR_NOERROR) {
|
||||||
strncpy(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS);
|
lstrcpynA(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1);
|
||||||
for (idx = strlen(buffer);
|
len = strlen(buffer);
|
||||||
idx < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; idx++)
|
memset(buffer+len, ' ', ACMFORMATTAGDETAILS_FORMATTAG_CHARS - len);
|
||||||
buffer[idx] = ' ';
|
|
||||||
wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
|
wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
|
||||||
"%d Ko/s",
|
"%d Ko/s",
|
||||||
(afd.pwfx->nAvgBytesPerSec + 512) / 1024);
|
(afd.pwfx->nAvgBytesPerSec + 512) / 1024);
|
||||||
|
|
|
@ -338,6 +338,7 @@ DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule,
|
||||||
{
|
{
|
||||||
WCHAR tmp[MAX_PATH];
|
WCHAR tmp[MAX_PATH];
|
||||||
WCHAR* ptr;
|
WCHAR* ptr;
|
||||||
|
int ptrlen;
|
||||||
|
|
||||||
if(!lpBaseName || !nSize) {
|
if(!lpBaseName || !nSize) {
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
@ -349,8 +350,9 @@ DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule,
|
||||||
return 0;
|
return 0;
|
||||||
TRACE("%s\n", debugstr_w(tmp));
|
TRACE("%s\n", debugstr_w(tmp));
|
||||||
if ((ptr = strrchrW(tmp, '\\')) != NULL) ptr++; else ptr = tmp;
|
if ((ptr = strrchrW(tmp, '\\')) != NULL) ptr++; else ptr = tmp;
|
||||||
strncpyW(lpBaseName, ptr, nSize);
|
ptrlen = strlenW(ptr);
|
||||||
return min(strlenW(ptr), nSize);
|
memcpy(lpBaseName, ptr, min(ptrlen+1,nSize) * sizeof(WCHAR));
|
||||||
|
return min(ptrlen, nSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
|
@ -163,7 +163,7 @@ static void TEXT_Ellipsify (HDC hdc, WCHAR *str, unsigned int max_len,
|
||||||
/* Now this should take only a couple iterations at most. */
|
/* Now this should take only a couple iterations at most. */
|
||||||
for ( ; ; )
|
for ( ; ; )
|
||||||
{
|
{
|
||||||
strncpyW (str + *len_str, ELLIPSISW, len_ellipsis);
|
memcpy(str + *len_str, ELLIPSISW, len_ellipsis*sizeof(WCHAR));
|
||||||
|
|
||||||
if (!GetTextExtentExPointW (hdc, str, *len_str + len_ellipsis, width,
|
if (!GetTextExtentExPointW (hdc, str, *len_str + len_ellipsis, width,
|
||||||
NULL, NULL, size)) break;
|
NULL, NULL, size)) break;
|
||||||
|
@ -178,7 +178,7 @@ static void TEXT_Ellipsify (HDC hdc, WCHAR *str, unsigned int max_len,
|
||||||
|
|
||||||
if (modstr)
|
if (modstr)
|
||||||
{
|
{
|
||||||
strncpyW (modstr, str, *len_str);
|
memcpy (modstr, str, *len_str * sizeof(WCHAR));
|
||||||
*(str+*len_str) = '\0';
|
*(str+*len_str) = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ static void TEXT_PathEllipsify (HDC hdc, WCHAR *str, unsigned int max_len,
|
||||||
|
|
||||||
/* overlap-safe movement to the right */
|
/* overlap-safe movement to the right */
|
||||||
memmove (lastSlash+len_ellipsis, lastSlash, len_trailing * sizeof(WCHAR));
|
memmove (lastSlash+len_ellipsis, lastSlash, len_trailing * sizeof(WCHAR));
|
||||||
strncpyW (lastSlash, ELLIPSISW, len_ellipsis);
|
memcpy (lastSlash, ELLIPSISW, len_ellipsis*sizeof(WCHAR));
|
||||||
len_trailing += len_ellipsis;
|
len_trailing += len_ellipsis;
|
||||||
/* From this point on lastSlash actually points to the ellipsis in front
|
/* From this point on lastSlash actually points to the ellipsis in front
|
||||||
* of the last slash and len_trailing includes the ellipsis
|
* of the last slash and len_trailing includes the ellipsis
|
||||||
|
|
|
@ -354,16 +354,18 @@ BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int f
|
||||||
}
|
}
|
||||||
else if (flags & MSG_PEEK && peek_msg)
|
else if (flags & MSG_PEEK && peek_msg)
|
||||||
{
|
{
|
||||||
if (len < strlen(peek_msg))
|
size_t peek_msg_len = strlen(peek_msg);
|
||||||
|
if (len < peek_msg_len)
|
||||||
FIXME("buffer isn't big enough. Do the expect us to wrap?\n");
|
FIXME("buffer isn't big enough. Do the expect us to wrap?\n");
|
||||||
strncpy(buf, peek_msg, len);
|
memcpy(buf, peek_msg, min(len,peek_msg_len+1));
|
||||||
*recvd = (strlen(peek_msg) <= len ? strlen(peek_msg) : len);
|
*recvd = min(len, peek_msg_len);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (peek_msg)
|
else if (peek_msg)
|
||||||
{
|
{
|
||||||
strncpy(buf, peek_msg, len);
|
size_t peek_msg_len = strlen(peek_msg);
|
||||||
peek_msg += *recvd = min(len, strlen(peek_msg));
|
memcpy(buf, peek_msg, min(len,peek_msg_len+1));
|
||||||
|
peek_msg += *recvd = min(len, peek_msg_len);
|
||||||
if (*peek_msg == '\0' || *(peek_msg - 1) == '\0')
|
if (*peek_msg == '\0' || *(peek_msg - 1) == '\0')
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, peek_msg_mem);
|
HeapFree(GetProcessHeap(), 0, peek_msg_mem);
|
||||||
|
@ -383,7 +385,7 @@ BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int f
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strncpy(peek_msg, buf, *recvd);
|
memcpy(peek_msg, buf, *recvd);
|
||||||
peek_msg[*recvd] = '\0';
|
peek_msg[*recvd] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue