[dlls/msacm/format.c] Strncpy elimination.
Peter Berg Larsen
pebl at math.ku.dk
Sun Mar 27 12:02:17 CST 2005
I have been checking the usage of strncpy, replacing where apropriate with
a memcpy or lstrcpyn[AW]. The first raw diff was 100kb, so there is bound
to be one or two slips. These are the first batch which I found to be
obvious, correct, and didnt need a special comment. Note with correct I
mean if there was a \0 bug before then it still there.
Changelog:
Janitorial Task: Check the usage of strncpy/strncpyW.
Index: dlls/msacm/format.c
===================================================================
RCS file: /home/wine/wine/dlls/msacm/format.c,v
retrieving revision 1.27
diff -u -r1.27 format.c
--- dlls/msacm/format.c 8 Sep 2004 01:37:24 -0000 1.27
+++ dlls/msacm/format.c 27 Mar 2005 16:56:19 -0000
@@ -72,7 +72,7 @@
if (acmDriverOpen(&had, hadid, 0) == MMSYSERR_NOERROR) {
ACMFORMATDETAILSA afd;
- unsigned int i, idx;
+ unsigned int i, len;
MMRESULT mmr;
char buffer[ACMFORMATDETAILS_FORMAT_CHARS+16];
@@ -88,10 +88,9 @@
afd.dwFormatIndex = i;
mmr = acmFormatDetailsA(had, &afd, ACM_FORMATDETAILSF_INDEX);
if (mmr == MMSYSERR_NOERROR) {
- strncpy(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS);
- for (idx = strlen(buffer);
- idx < ACMFORMATTAGDETAILS_FORMATTAG_CHARS; idx++)
- buffer[idx] = ' ';
+ lstrcpynA(buffer, afd.szFormat, ACMFORMATTAGDETAILS_FORMATTAG_CHARS + 1);
+ len = strlen(buffer);
+ memset(buffer+len, ' ', ACMFORMATTAGDETAILS_FORMATTAG_CHARS - len);
wsprintfA(buffer + ACMFORMATTAGDETAILS_FORMATTAG_CHARS,
"%d Ko/s",
(afd.pwfx->nAvgBytesPerSec + 512) / 1024);
More information about the wine-patches
mailing list