Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
429433b3
Commit
429433b3
authored
Apr 18, 2006
by
Skip Montanaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C++ compiler cleanup: bunch-o-casts, plus use of unsigned loop index var in a couple places
parent
3fca4636
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
28 deletions
+29
-28
Objects/complexobject.c
Objects/complexobject.c
+1
-1
Objects/floatobject.c
Objects/floatobject.c
+1
-1
Objects/intobject.c
Objects/intobject.c
+18
-17
Objects/longobject.c
Objects/longobject.c
+2
-2
Objects/stringobject.c
Objects/stringobject.c
+1
-1
Objects/typeobject.c
Objects/typeobject.c
+6
-6
No files found.
Objects/complexobject.c
View file @
429433b3
...
...
@@ -688,7 +688,7 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
}
#ifdef Py_USING_UNICODE
else
if
(
PyUnicode_Check
(
v
))
{
if
(
PyUnicode_GET_SIZE
(
v
)
>=
sizeof
(
s_buffer
))
{
if
(
PyUnicode_GET_SIZE
(
v
)
>=
(
Py_ssize_t
)
sizeof
(
s_buffer
))
{
PyErr_SetString
(
PyExc_ValueError
,
"complex() literal too large to convert"
);
return
NULL
;
...
...
Objects/floatobject.c
View file @
429433b3
...
...
@@ -97,7 +97,7 @@ PyFloat_FromString(PyObject *v, char **pend)
}
#ifdef Py_USING_UNICODE
else
if
(
PyUnicode_Check
(
v
))
{
if
(
PyUnicode_GET_SIZE
(
v
)
>=
sizeof
(
s_buffer
))
{
if
(
PyUnicode_GET_SIZE
(
v
)
>=
(
Py_ssize_t
)
sizeof
(
s_buffer
))
{
PyErr_SetString
(
PyExc_ValueError
,
"Unicode float() literal too long to convert"
);
return
NULL
;
...
...
Objects/intobject.c
View file @
429433b3
...
...
@@ -255,18 +255,18 @@ PyInt_AsUnsignedLongMask(register PyObject *op)
if
(
op
==
NULL
||
(
nb
=
op
->
ob_type
->
tp_as_number
)
==
NULL
||
nb
->
nb_int
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"an integer is required"
);
return
-
1
;
return
(
unsigned
long
)
-
1
;
}
io
=
(
PyIntObject
*
)
(
*
nb
->
nb_int
)
(
op
);
if
(
io
==
NULL
)
return
-
1
;
return
(
unsigned
long
)
-
1
;
if
(
!
PyInt_Check
(
io
))
{
if
(
PyLong_Check
(
io
))
{
val
=
PyLong_AsUnsignedLongMask
((
PyObject
*
)
io
);
Py_DECREF
(
io
);
if
(
PyErr_Occurred
())
return
-
1
;
return
(
unsigned
long
)
-
1
;
return
val
;
}
else
...
...
@@ -274,7 +274,7 @@ PyInt_AsUnsignedLongMask(register PyObject *op)
Py_DECREF
(
io
);
PyErr_SetString
(
PyExc_TypeError
,
"nb_int should return int object"
);
return
-
1
;
return
(
unsigned
long
)
-
1
;
}
}
...
...
@@ -300,18 +300,18 @@ PyInt_AsUnsignedLongLongMask(register PyObject *op)
if
(
op
==
NULL
||
(
nb
=
op
->
ob_type
->
tp_as_number
)
==
NULL
||
nb
->
nb_int
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"an integer is required"
);
return
-
1
;
return
(
unsigned
PY_LONG_LONG
)
-
1
;
}
io
=
(
PyIntObject
*
)
(
*
nb
->
nb_int
)
(
op
);
if
(
io
==
NULL
)
return
-
1
;
return
(
unsigned
PY_LONG_LONG
)
-
1
;
if
(
!
PyInt_Check
(
io
))
{
if
(
PyLong_Check
(
io
))
{
val
=
PyLong_AsUnsignedLongLongMask
((
PyObject
*
)
io
);
Py_DECREF
(
io
);
if
(
PyErr_Occurred
())
return
-
1
;
return
(
unsigned
PY_LONG_LONG
)
-
1
;
return
val
;
}
else
...
...
@@ -319,7 +319,7 @@ PyInt_AsUnsignedLongLongMask(register PyObject *op)
Py_DECREF
(
io
);
PyErr_SetString
(
PyExc_TypeError
,
"nb_int should return int object"
);
return
-
1
;
return
(
unsigned
PY_LONG_LONG
)
-
1
;
}
}
...
...
@@ -1152,6 +1152,7 @@ PyInt_Fini(void)
PyIntObject
*
p
;
PyIntBlock
*
list
,
*
next
;
int
i
;
unsigned
int
ctr
;
int
bc
,
bf
;
/* block count, number of freed blocks */
int
irem
,
isum
;
/* remaining unfreed ints per block, total */
...
...
@@ -1174,9 +1175,9 @@ PyInt_Fini(void)
while
(
list
!=
NULL
)
{
bc
++
;
irem
=
0
;
for
(
i
=
0
,
p
=
&
list
->
objects
[
0
];
i
<
N_INTOBJECTS
;
i
++
,
p
++
)
{
for
(
ctr
=
0
,
p
=
&
list
->
objects
[
0
];
ctr
<
N_INTOBJECTS
;
ctr
++
,
p
++
)
{
if
(
PyInt_CheckExact
(
p
)
&&
p
->
ob_refcnt
!=
0
)
irem
++
;
}
...
...
@@ -1184,9 +1185,9 @@ PyInt_Fini(void)
if
(
irem
)
{
list
->
next
=
block_list
;
block_list
=
list
;
for
(
i
=
0
,
p
=
&
list
->
objects
[
0
];
i
<
N_INTOBJECTS
;
i
++
,
p
++
)
{
for
(
ctr
=
0
,
p
=
&
list
->
objects
[
0
];
ctr
<
N_INTOBJECTS
;
ctr
++
,
p
++
)
{
if
(
!
PyInt_CheckExact
(
p
)
||
p
->
ob_refcnt
==
0
)
{
p
->
ob_type
=
(
struct
_typeobject
*
)
...
...
@@ -1227,9 +1228,9 @@ PyInt_Fini(void)
if
(
Py_VerboseFlag
>
1
)
{
list
=
block_list
;
while
(
list
!=
NULL
)
{
for
(
i
=
0
,
p
=
&
list
->
objects
[
0
];
i
<
N_INTOBJECTS
;
i
++
,
p
++
)
{
for
(
ctr
=
0
,
p
=
&
list
->
objects
[
0
];
ctr
<
N_INTOBJECTS
;
ctr
++
,
p
++
)
{
if
(
PyInt_CheckExact
(
p
)
&&
p
->
ob_refcnt
!=
0
)
/* XXX(twouters) cast refcount to
long until %zd is universally
...
...
Objects/longobject.c
View file @
429433b3
...
...
@@ -419,7 +419,7 @@ _PyLong_NumBits(PyObject *vv)
digit
msd
=
v
->
ob_digit
[
ndigits
-
1
];
result
=
(
ndigits
-
1
)
*
SHIFT
;
if
(
result
/
SHIFT
!=
ndigits
-
1
)
if
(
result
/
SHIFT
!=
(
size_t
)(
ndigits
-
1
)
)
goto
Overflow
;
do
{
++
result
;
...
...
@@ -953,7 +953,7 @@ PyLong_AsUnsignedLongLong(PyObject *vv)
if
(
vv
==
NULL
||
!
PyLong_Check
(
vv
))
{
PyErr_BadInternalCall
();
return
-
1
;
return
(
unsigned
PY_LONG_LONG
)
-
1
;
}
res
=
_PyLong_AsByteArray
(
...
...
Objects/stringobject.c
View file @
429433b3
...
...
@@ -746,7 +746,7 @@ PyString_AsStringAndSize(register PyObject *obj,
*
s
=
PyString_AS_STRING
(
obj
);
if
(
len
!=
NULL
)
*
len
=
PyString_GET_SIZE
(
obj
);
else
if
(
strlen
(
*
s
)
!=
PyString_GET_SIZE
(
obj
))
{
else
if
(
strlen
(
*
s
)
!=
(
size_t
)
PyString_GET_SIZE
(
obj
))
{
PyErr_SetString
(
PyExc_TypeError
,
"expected string without null bytes"
);
return
-
1
;
...
...
Objects/typeobject.c
View file @
429433b3
...
...
@@ -1118,12 +1118,12 @@ set_mro_error(PyObject *to_merge, int *remain)
off
=
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"Cannot create a \
consistent method resolution
\n
order (MRO) for bases"
);
i
=
0
;
while
(
PyDict_Next
(
set
,
&
i
,
&
k
,
&
v
)
&&
off
<
sizeof
(
buf
))
{
while
(
PyDict_Next
(
set
,
&
i
,
&
k
,
&
v
)
&&
(
size_t
)
off
<
sizeof
(
buf
))
{
PyObject
*
name
=
class_name
(
k
);
off
+=
PyOS_snprintf
(
buf
+
off
,
sizeof
(
buf
)
-
off
,
" %s"
,
name
?
PyString_AS_STRING
(
name
)
:
"?"
);
Py_XDECREF
(
name
);
if
(
--
n
&&
off
+
1
<
sizeof
(
buf
))
{
if
(
--
n
&&
(
size_t
)(
off
+
1
)
<
sizeof
(
buf
))
{
buf
[
off
++
]
=
','
;
buf
[
off
]
=
'\0'
;
}
...
...
@@ -5186,16 +5186,16 @@ slotptr(PyTypeObject *type, int ioffset)
/* Note: this depends on the order of the members of PyHeapTypeObject! */
assert
(
offset
>=
0
);
assert
(
offset
<
offsetof
(
PyHeapTypeObject
,
as_buffer
));
if
(
offset
>=
offsetof
(
PyHeapTypeObject
,
as_sequence
))
{
assert
(
(
size_t
)
offset
<
offsetof
(
PyHeapTypeObject
,
as_buffer
));
if
(
(
size_t
)
offset
>=
offsetof
(
PyHeapTypeObject
,
as_sequence
))
{
ptr
=
(
char
*
)
type
->
tp_as_sequence
;
offset
-=
offsetof
(
PyHeapTypeObject
,
as_sequence
);
}
else
if
(
offset
>=
offsetof
(
PyHeapTypeObject
,
as_mapping
))
{
else
if
(
(
size_t
)
offset
>=
offsetof
(
PyHeapTypeObject
,
as_mapping
))
{
ptr
=
(
char
*
)
type
->
tp_as_mapping
;
offset
-=
offsetof
(
PyHeapTypeObject
,
as_mapping
);
}
else
if
(
offset
>=
offsetof
(
PyHeapTypeObject
,
as_number
))
{
else
if
(
(
size_t
)
offset
>=
offsetof
(
PyHeapTypeObject
,
as_number
))
{
ptr
=
(
char
*
)
type
->
tp_as_number
;
offset
-=
offsetof
(
PyHeapTypeObject
,
as_number
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment