mirror of https://github.com/python/cpython
Fix various minor issues discovered with static analysis using Visual Studio 2005 Team System.
Removed obsolete comment, since .dll modules are no longer supported on windows, only .pyd.
This commit is contained in:
parent
8ff1f6a69e
commit
5e4e31f76a
|
@ -64,6 +64,7 @@
|
||||||
|
|
||||||
#ifdef MS_WIN32
|
#ifdef MS_WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <tchar.h>
|
||||||
#else
|
#else
|
||||||
#include "ctypes_dlfcn.h"
|
#include "ctypes_dlfcn.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -97,9 +98,9 @@ static TCHAR *FormatError(DWORD code)
|
||||||
0,
|
0,
|
||||||
NULL);
|
NULL);
|
||||||
if (n) {
|
if (n) {
|
||||||
while (isspace(lpMsgBuf[n-1]))
|
while (_istspace(lpMsgBuf[n-1]))
|
||||||
--n;
|
--n;
|
||||||
lpMsgBuf[n] = '\0'; /* rstrip() */
|
lpMsgBuf[n] = _T('\0'); /* rstrip() */
|
||||||
}
|
}
|
||||||
return lpMsgBuf;
|
return lpMsgBuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1165,7 +1165,8 @@ binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) ||
|
((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) ||
|
||||||
((data[in] < 33) &&
|
((data[in] < 33) &&
|
||||||
(data[in] != '\r') && (data[in] != '\n') &&
|
(data[in] != '\r') && (data[in] != '\n') &&
|
||||||
(quotetabs && ((data[in] != '\t') || (data[in] != ' ')))))
|
(!quotetabs ||
|
||||||
|
(quotetabs && ((data[in] != '\t') && (data[in] != ' '))))))
|
||||||
{
|
{
|
||||||
if ((linelen + 3) >= MAXLINESIZE) {
|
if ((linelen + 3) >= MAXLINESIZE) {
|
||||||
linelen = 0;
|
linelen = 0;
|
||||||
|
@ -1235,7 +1236,8 @@ binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) ||
|
((data[in] == '\t' || data[in] == ' ') && (in + 1 == datalen)) ||
|
||||||
((data[in] < 33) &&
|
((data[in] < 33) &&
|
||||||
(data[in] != '\r') && (data[in] != '\n') &&
|
(data[in] != '\r') && (data[in] != '\n') &&
|
||||||
(quotetabs && ((data[in] != '\t') || (data[in] != ' ')))))
|
(!quotetabs ||
|
||||||
|
(quotetabs && ((data[in] != '\t') && (data[in] != ' '))))))
|
||||||
{
|
{
|
||||||
if ((linelen + 3 )>= MAXLINESIZE) {
|
if ((linelen + 3 )>= MAXLINESIZE) {
|
||||||
odata[out++] = '=';
|
odata[out++] = '=';
|
||||||
|
|
|
@ -533,11 +533,12 @@ read_file(Unpicklerobject *self, char **s, Py_ssize_t n)
|
||||||
self->buf_size = size;
|
self->buf_size = size;
|
||||||
}
|
}
|
||||||
else if (n > self->buf_size) {
|
else if (n > self->buf_size) {
|
||||||
self->buf = (char *)realloc(self->buf, n);
|
char *newbuf = (char *)realloc(self->buf, n);
|
||||||
if (!self->buf) {
|
if (!newbuf) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
self->buf = newbuf;
|
||||||
self->buf_size = n;
|
self->buf_size = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,6 +577,7 @@ readline_file(Unpicklerobject *self, char **s)
|
||||||
i = 0;
|
i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
int bigger;
|
int bigger;
|
||||||
|
char *newbuf;
|
||||||
for (; i < (self->buf_size - 1); i++) {
|
for (; i < (self->buf_size - 1); i++) {
|
||||||
if (feof(self->fp) ||
|
if (feof(self->fp) ||
|
||||||
(self->buf[i] = getc(self->fp)) == '\n') {
|
(self->buf[i] = getc(self->fp)) == '\n') {
|
||||||
|
@ -589,11 +591,12 @@ readline_file(Unpicklerobject *self, char **s)
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
self->buf = (char *)realloc(self->buf, bigger);
|
newbuf = (char *)realloc(self->buf, bigger);
|
||||||
if (!self->buf) {
|
if (!newbuf) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
self->buf = newbuf;
|
||||||
self->buf_size = bigger;
|
self->buf_size = bigger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4365,17 +4368,19 @@ load_mark(Unpicklerobject *self)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((self->num_marks + 1) >= self->marks_size) {
|
if ((self->num_marks + 1) >= self->marks_size) {
|
||||||
|
int *marks;
|
||||||
s=self->marks_size+20;
|
s=self->marks_size+20;
|
||||||
if (s <= self->num_marks) s=self->num_marks + 1;
|
if (s <= self->num_marks) s=self->num_marks + 1;
|
||||||
if (self->marks == NULL)
|
if (self->marks == NULL)
|
||||||
self->marks=(int *)malloc(s * sizeof(int));
|
marks=(int *)malloc(s * sizeof(int));
|
||||||
else
|
else
|
||||||
self->marks=(int *)realloc(self->marks,
|
marks=(int *)realloc(self->marks,
|
||||||
s * sizeof(int));
|
s * sizeof(int));
|
||||||
if (! self->marks) {
|
if (!marks) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
self->marks = marks;
|
||||||
self->marks_size = s;
|
self->marks_size = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,13 +339,17 @@ O_seek(Oobject *self, PyObject *args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position > self->buf_size) {
|
if (position > self->buf_size) {
|
||||||
|
char *newbuf;
|
||||||
self->buf_size*=2;
|
self->buf_size*=2;
|
||||||
if (self->buf_size <= position) self->buf_size=position+1;
|
if (self->buf_size <= position) self->buf_size=position+1;
|
||||||
self->buf = (char*) realloc(self->buf,self->buf_size);
|
newbuf = (char*) realloc(self->buf,self->buf_size);
|
||||||
if (!self->buf) {
|
if (!newbuf) {
|
||||||
|
free(self->buf);
|
||||||
|
self->buf = 0;
|
||||||
self->buf_size=self->pos=0;
|
self->buf_size=self->pos=0;
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
self->buf = newbuf;
|
||||||
}
|
}
|
||||||
else if (position < 0) position=0;
|
else if (position < 0) position=0;
|
||||||
|
|
||||||
|
@ -366,6 +370,7 @@ static int
|
||||||
O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
|
O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
|
||||||
Py_ssize_t newl;
|
Py_ssize_t newl;
|
||||||
Oobject *oself;
|
Oobject *oself;
|
||||||
|
char *newbuf;
|
||||||
|
|
||||||
if (!IO__opencheck(IOOOBJECT(self))) return -1;
|
if (!IO__opencheck(IOOOBJECT(self))) return -1;
|
||||||
oself = (Oobject *)self;
|
oself = (Oobject *)self;
|
||||||
|
@ -377,12 +382,15 @@ O_cwrite(PyObject *self, const char *c, Py_ssize_t l) {
|
||||||
assert(newl + 1 < INT_MAX);
|
assert(newl + 1 < INT_MAX);
|
||||||
oself->buf_size = (int)(newl+1);
|
oself->buf_size = (int)(newl+1);
|
||||||
}
|
}
|
||||||
oself->buf = (char*)realloc(oself->buf, oself->buf_size);
|
newbuf = (char*)realloc(oself->buf, oself->buf_size);
|
||||||
if (!oself->buf) {
|
if (!newbuf) {
|
||||||
PyErr_SetString(PyExc_MemoryError,"out of memory");
|
PyErr_SetString(PyExc_MemoryError,"out of memory");
|
||||||
|
free(oself->buf);
|
||||||
|
oself->buf = 0;
|
||||||
oself->buf_size = oself->pos = 0;
|
oself->buf_size = oself->pos = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
oself->buf = newbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(oself->buf+oself->pos,c,l);
|
memcpy(oself->buf+oself->pos,c,l);
|
||||||
|
|
|
@ -4788,18 +4788,19 @@ _PyPopenCreateProcess(char *cmdstring,
|
||||||
(sizeof(modulepath)/sizeof(modulepath[0]))
|
(sizeof(modulepath)/sizeof(modulepath[0]))
|
||||||
-strlen(modulepath));
|
-strlen(modulepath));
|
||||||
if (stat(modulepath, &statinfo) != 0) {
|
if (stat(modulepath, &statinfo) != 0) {
|
||||||
|
size_t mplen = sizeof(modulepath)/sizeof(modulepath[0]);
|
||||||
/* Eeek - file-not-found - possibly an embedding
|
/* Eeek - file-not-found - possibly an embedding
|
||||||
situation - see if we can locate it in sys.prefix
|
situation - see if we can locate it in sys.prefix
|
||||||
*/
|
*/
|
||||||
strncpy(modulepath,
|
strncpy(modulepath,
|
||||||
Py_GetExecPrefix(),
|
Py_GetExecPrefix(),
|
||||||
sizeof(modulepath)/sizeof(modulepath[0]));
|
mplen);
|
||||||
|
modulepath[mplen-1] = '\0';
|
||||||
if (modulepath[strlen(modulepath)-1] != '\\')
|
if (modulepath[strlen(modulepath)-1] != '\\')
|
||||||
strcat(modulepath, "\\");
|
strcat(modulepath, "\\");
|
||||||
strncat(modulepath,
|
strncat(modulepath,
|
||||||
szConsoleSpawn,
|
szConsoleSpawn,
|
||||||
(sizeof(modulepath)/sizeof(modulepath[0]))
|
mplen-strlen(modulepath));
|
||||||
-strlen(modulepath));
|
|
||||||
/* No where else to look - raise an easily identifiable
|
/* No where else to look - raise an easily identifiable
|
||||||
error, rather than leaving Windows to report
|
error, rather than leaving Windows to report
|
||||||
"file not found" - as the user is probably blissfully
|
"file not found" - as the user is probably blissfully
|
||||||
|
|
|
@ -699,7 +699,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
|
||||||
case REG_DWORD:
|
case REG_DWORD:
|
||||||
if (value != Py_None && !PyInt_Check(value))
|
if (value != Py_None && !PyInt_Check(value))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
*retDataBuf = (BYTE *)PyMem_NEW(DWORD, sizeof(DWORD));
|
*retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1);
|
||||||
if (*retDataBuf==NULL){
|
if (*retDataBuf==NULL){
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -13,16 +13,8 @@
|
||||||
const struct filedescr _PyImport_DynLoadFiletab[] = {
|
const struct filedescr _PyImport_DynLoadFiletab[] = {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
{"_d.pyd", "rb", C_EXTENSION},
|
{"_d.pyd", "rb", C_EXTENSION},
|
||||||
/* Temporarily disable .dll, to avoid conflicts between sqlite3.dll
|
|
||||||
and the sqlite3 package. If this needs to be reverted for 2.5,
|
|
||||||
some other solution for the naming conflict must be found.
|
|
||||||
{"_d.dll", "rb", C_EXTENSION},
|
|
||||||
*/
|
|
||||||
#else
|
#else
|
||||||
{".pyd", "rb", C_EXTENSION},
|
{".pyd", "rb", C_EXTENSION},
|
||||||
/* Likewise
|
|
||||||
{".dll", "rb", C_EXTENSION},
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
{0, 0}
|
{0, 0}
|
||||||
};
|
};
|
||||||
|
|
|
@ -202,12 +202,12 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
|
||||||
* too many threads".
|
* too many threads".
|
||||||
*/
|
*/
|
||||||
dprintf(("%ld: PyThread_start_new_thread failed: %p errno %d\n",
|
dprintf(("%ld: PyThread_start_new_thread failed: %p errno %d\n",
|
||||||
PyThread_get_thread_ident(), rv, errno));
|
PyThread_get_thread_ident(), (void*)rv, errno));
|
||||||
obj.id = -1;
|
obj.id = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dprintf(("%ld: PyThread_start_new_thread succeeded: %p\n",
|
dprintf(("%ld: PyThread_start_new_thread succeeded: %p\n",
|
||||||
PyThread_get_thread_ident(), rv));
|
PyThread_get_thread_ident(), (void*)rv));
|
||||||
/* wait for thread to initialize, so we can get its id */
|
/* wait for thread to initialize, so we can get its id */
|
||||||
WaitForSingleObject(obj.done, INFINITE);
|
WaitForSingleObject(obj.done, INFINITE);
|
||||||
assert(obj.id != -1);
|
assert(obj.id != -1);
|
||||||
|
@ -333,7 +333,7 @@ PyThread_release_lock(PyThread_type_lock aLock)
|
||||||
dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
|
dprintf(("%ld: PyThread_release_lock(%p) called\n", PyThread_get_thread_ident(),aLock));
|
||||||
|
|
||||||
if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock)))
|
if (!(aLock && LeaveNonRecursiveMutex((PNRMUTEX) aLock)))
|
||||||
dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError()));
|
dprintf(("%ld: Could not PyThread_release_lock(%p) error: %ld\n", PyThread_get_thread_ident(), aLock, GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* minimum/maximum thread stack sizes supported */
|
/* minimum/maximum thread stack sizes supported */
|
||||||
|
|
Loading…
Reference in New Issue