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
1a2252ed
Commit
1a2252ed
authored
May 06, 2019
by
Zackery Spytz
Committed by
Brett Cannon
May 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36594: Fix incorrect use of %p in format strings (GH-12769)
In addition, fix some other minor violations of C99.
parent
ae2c32f3
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
26 additions
and
24 deletions
+26
-24
Misc/NEWS.d/next/Core and Builtins/2019-04-10-18-12-11.bpo-36594.fbnJAc.rst
...ore and Builtins/2019-04-10-18-12-11.bpo-36594.fbnJAc.rst
+2
-0
Modules/_ctypes/_ctypes_test.c
Modules/_ctypes/_ctypes_test.c
+4
-4
Modules/_ctypes/callproc.c
Modules/_ctypes/callproc.c
+2
-2
Modules/_xxsubinterpretersmodule.c
Modules/_xxsubinterpretersmodule.c
+1
-1
Modules/hashtable.c
Modules/hashtable.c
+1
-1
Objects/object.c
Objects/object.c
+5
-5
Objects/obmalloc.c
Objects/obmalloc.c
+1
-1
Objects/unicodeobject.c
Objects/unicodeobject.c
+3
-3
Programs/_freeze_importlib.c
Programs/_freeze_importlib.c
+1
-1
Python/sysmodule.c
Python/sysmodule.c
+4
-4
Python/thread_pthread.h
Python/thread_pthread.h
+2
-2
No files found.
Misc/NEWS.d/next/Core and Builtins/2019-04-10-18-12-11.bpo-36594.fbnJAc.rst
0 → 100644
View file @
1a2252ed
Fix incorrect use of ``%p`` in format strings.
Patch by Zackery Spytz.
Modules/_ctypes/_ctypes_test.c
View file @
1a2252ed
...
...
@@ -87,7 +87,7 @@ EXPORT(void)testfunc_array(int values[4])
EXPORT
(
long
double
)
testfunc_Ddd
(
double
a
,
double
b
)
{
long
double
result
=
(
long
double
)(
a
*
b
);
printf
(
"testfunc_Ddd(%p, %p)
\n
"
,
&
a
,
&
b
);
printf
(
"testfunc_Ddd(%p, %p)
\n
"
,
(
void
*
)
&
a
,
(
void
*
)
&
b
);
printf
(
"testfunc_Ddd(%g, %g)
\n
"
,
a
,
b
);
return
result
;
}
...
...
@@ -95,7 +95,7 @@ EXPORT(long double)testfunc_Ddd(double a, double b)
EXPORT
(
long
double
)
testfunc_DDD
(
long
double
a
,
long
double
b
)
{
long
double
result
=
a
*
b
;
printf
(
"testfunc_DDD(%p, %p)
\n
"
,
&
a
,
&
b
);
printf
(
"testfunc_DDD(%p, %p)
\n
"
,
(
void
*
)
&
a
,
(
void
*
)
&
b
);
printf
(
"testfunc_DDD(%Lg, %Lg)
\n
"
,
a
,
b
);
return
result
;
}
...
...
@@ -103,7 +103,7 @@ EXPORT(long double)testfunc_DDD(long double a, long double b)
EXPORT
(
int
)
testfunc_iii
(
int
a
,
int
b
)
{
int
result
=
a
*
b
;
printf
(
"testfunc_iii(%p, %p)
\n
"
,
&
a
,
&
b
);
printf
(
"testfunc_iii(%p, %p)
\n
"
,
(
void
*
)
&
a
,
(
void
*
)
&
b
);
return
result
;
}
...
...
@@ -361,7 +361,7 @@ static void _xxx_init(void *(*Xalloc)(int), void (*Xfree)(void *))
{
void
*
ptr
;
printf
(
"_xxx_init got %p %p
\n
"
,
Xalloc
,
Xfree
);
printf
(
"_xxx_init got %p %p
\n
"
,
(
void
*
)
Xalloc
,
(
void
*
)
Xfree
);
printf
(
"calling
\n
"
);
ptr
=
Xalloc
(
32
);
Xfree
(
ptr
);
...
...
Modules/_ctypes/callproc.c
View file @
1a2252ed
...
...
@@ -531,11 +531,11 @@ PyCArg_repr(PyCArgObject *self)
default:
if
(
is_literal_char
((
unsigned
char
)
self
->
tag
))
{
sprintf
(
buffer
,
"<cparam '%c' at %p>"
,
(
unsigned
char
)
self
->
tag
,
self
);
(
unsigned
char
)
self
->
tag
,
(
void
*
)
self
);
}
else
{
sprintf
(
buffer
,
"<cparam 0x%02x at %p>"
,
(
unsigned
char
)
self
->
tag
,
self
);
(
unsigned
char
)
self
->
tag
,
(
void
*
)
self
);
}
break
;
}
...
...
Modules/_xxsubinterpretersmodule.c
View file @
1a2252ed
...
...
@@ -1250,7 +1250,7 @@ _channel_finish_closing(struct _channel *chan) {
// Do the things that would have been done in _channels_close().
ref
->
chan
=
NULL
;
_channel_free
(
chan
);
}
;
}
/* "high"-level channel-related functions */
...
...
Modules/hashtable.c
View file @
1a2252ed
...
...
@@ -240,7 +240,7 @@ _Py_hashtable_print_stats(_Py_hashtable_t *ht)
}
printf
(
"hash table %p: entries=%"
PY_FORMAT_SIZE_T
"u/%"
PY_FORMAT_SIZE_T
"u (%.0f%%), "
,
ht
,
ht
->
entries
,
ht
->
num_buckets
,
load
*
100
.
0
);
(
void
*
)
ht
,
ht
->
entries
,
ht
->
num_buckets
,
load
*
100
.
0
);
if
(
nchains
)
printf
(
"avg_chain_len=%.1f, "
,
(
double
)
total_chain_len
/
nchains
);
printf
(
"max_chain_len=%"
PY_FORMAT_SIZE_T
"u, %"
PY_FORMAT_SIZE_T
"u KiB
\n
"
,
...
...
Objects/object.c
View file @
1a2252ed
...
...
@@ -385,7 +385,7 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
universally available */
Py_BEGIN_ALLOW_THREADS
fprintf
(
fp
,
"<refcnt %ld at %p>"
,
(
long
)
op
->
ob_refcnt
,
op
);
(
long
)
op
->
ob_refcnt
,
(
void
*
)
op
);
Py_END_ALLOW_THREADS
}
else
{
...
...
@@ -499,7 +499,7 @@ _PyObject_Dump(PyObject* op)
"address : %p
\n
"
,
Py_TYPE
(
op
)
==
NULL
?
"NULL"
:
Py_TYPE
(
op
)
->
tp_name
,
(
long
)
op
->
ob_refcnt
,
op
);
(
void
*
)
op
);
fflush
(
stderr
);
}
...
...
@@ -1894,7 +1894,7 @@ _Py_PrintReferences(FILE *fp)
PyObject
*
op
;
fprintf
(
fp
,
"Remaining objects:
\n
"
);
for
(
op
=
refchain
.
_ob_next
;
op
!=
&
refchain
;
op
=
op
->
_ob_next
)
{
fprintf
(
fp
,
"%p [%"
PY_FORMAT_SIZE_T
"d] "
,
op
,
op
->
ob_refcnt
);
fprintf
(
fp
,
"%p [%"
PY_FORMAT_SIZE_T
"d] "
,
(
void
*
)
op
,
op
->
ob_refcnt
);
if
(
PyObject_Print
(
op
,
fp
,
0
)
!=
0
)
PyErr_Clear
();
putc
(
'\n'
,
fp
);
...
...
@@ -1910,7 +1910,7 @@ _Py_PrintReferenceAddresses(FILE *fp)
PyObject
*
op
;
fprintf
(
fp
,
"Remaining object addresses:
\n
"
);
for
(
op
=
refchain
.
_ob_next
;
op
!=
&
refchain
;
op
=
op
->
_ob_next
)
fprintf
(
fp
,
"%p [%"
PY_FORMAT_SIZE_T
"d] %s
\n
"
,
op
,
fprintf
(
fp
,
"%p [%"
PY_FORMAT_SIZE_T
"d] %s
\n
"
,
(
void
*
)
op
,
op
->
ob_refcnt
,
Py_TYPE
(
op
)
->
tp_name
);
}
...
...
@@ -2167,7 +2167,7 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
fprintf
(
stderr
,
"<object: ob_type=NULL>
\n
"
);
}
else
if
(
_PyObject_IsFreed
((
PyObject
*
)
Py_TYPE
(
obj
)))
{
fprintf
(
stderr
,
"<object: freed type %p>
\n
"
,
Py_TYPE
(
obj
));
fprintf
(
stderr
,
"<object: freed type %p>
\n
"
,
(
void
*
)
Py_TYPE
(
obj
));
}
else
{
/* Diplay the traceback where the object has been allocated.
...
...
Objects/obmalloc.c
View file @
1a2252ed
...
...
@@ -2354,7 +2354,7 @@ _PyObject_DebugDumpAddress(const void *p)
}
tail
=
q
+
nbytes
;
fprintf
(
stderr
,
" The %d pad bytes at tail=%p are "
,
SST
,
tail
);
fprintf
(
stderr
,
" The %d pad bytes at tail=%p are "
,
SST
,
(
void
*
)
tail
);
ok
=
1
;
for
(
i
=
0
;
i
<
SST
;
++
i
)
{
if
(
tail
[
i
]
!=
FORBIDDENBYTE
)
{
...
...
Objects/unicodeobject.c
View file @
1a2252ed
...
...
@@ -1251,7 +1251,7 @@ void *_PyUnicode_compact_data(void *unicode_raw) {
}
void
*
_PyUnicode_data
(
void
*
unicode_raw
)
{
PyObject
*
unicode
=
_PyObject_CAST
(
unicode_raw
);
printf
(
"obj %p
\n
"
,
unicode
);
printf
(
"obj %p
\n
"
,
(
void
*
)
unicode
);
printf
(
"compact %d
\n
"
,
PyUnicode_IS_COMPACT
(
unicode
));
printf
(
"compact ascii %d
\n
"
,
PyUnicode_IS_COMPACT_ASCII
(
unicode
));
printf
(
"ascii op %p
\n
"
,
((
void
*
)((
PyASCIIObject
*
)(
unicode
)
+
1
)));
...
...
@@ -1282,14 +1282,14 @@ _PyUnicode_Dump(PyObject *op)
if
(
ascii
->
wstr
==
data
)
printf
(
"shared "
);
printf
(
"wstr=%p"
,
ascii
->
wstr
);
printf
(
"wstr=%p"
,
(
void
*
)
ascii
->
wstr
);
if
(
!
(
ascii
->
state
.
ascii
==
1
&&
ascii
->
state
.
compact
==
1
))
{
printf
(
" (%"
PY_FORMAT_SIZE_T
"u), "
,
compact
->
wstr_length
);
if
(
!
ascii
->
state
.
compact
&&
compact
->
utf8
==
unicode
->
data
.
any
)
printf
(
"shared "
);
printf
(
"utf8=%p (%"
PY_FORMAT_SIZE_T
"u)"
,
compact
->
utf8
,
compact
->
utf8_length
);
(
void
*
)
compact
->
utf8
,
compact
->
utf8_length
);
}
printf
(
", data=%p
\n
"
,
data
);
}
...
...
Programs/_freeze_importlib.c
View file @
1a2252ed
...
...
@@ -127,7 +127,7 @@ main(int argc, char *argv[])
size_t
i
,
end
=
Py_MIN
(
n
+
16
,
data_size
);
fprintf
(
outfile
,
" "
);
for
(
i
=
n
;
i
<
end
;
i
++
)
{
fprintf
(
outfile
,
"%
d
,"
,
(
unsigned
int
)
data
[
i
]);
fprintf
(
outfile
,
"%
u
,"
,
(
unsigned
int
)
data
[
i
]);
}
fprintf
(
outfile
,
"
\n
"
);
}
...
...
Python/sysmodule.c
View file @
1a2252ed
...
...
@@ -1750,7 +1750,7 @@ _alloc_preinit_entry(const wchar_t *value)
PyMem_SetAllocator
(
PYMEM_DOMAIN_RAW
,
&
old_alloc
);
return
node
;
}
;
}
static
int
_append_preinit_entry
(
_Py_PreInitEntry
*
optionlist
,
const
wchar_t
*
value
)
...
...
@@ -1772,7 +1772,7 @@ _append_preinit_entry(_Py_PreInitEntry *optionlist, const wchar_t *value)
last_entry
->
next
=
new_entry
;
}
return
0
;
}
;
}
static
void
_clear_preinit_entries
(
_Py_PreInitEntry
*
optionlist
)
...
...
@@ -1789,7 +1789,7 @@ _clear_preinit_entries(_Py_PreInitEntry *optionlist)
current
=
next
;
}
PyMem_SetAllocator
(
PYMEM_DOMAIN_RAW
,
&
old_alloc
);
}
;
}
static
void
_clear_all_preinit_options
(
void
)
...
...
@@ -1820,7 +1820,7 @@ _PySys_ReadPreInitOptions(void)
_clear_all_preinit_options
();
return
0
;
}
;
}
static
PyObject
*
get_warnoptions
(
void
)
...
...
Python/thread_pthread.h
View file @
1a2252ed
...
...
@@ -339,7 +339,7 @@ PyThread_allocate_lock(void)
}
}
dprintf
((
"PyThread_allocate_lock() -> %p
\n
"
,
lock
));
dprintf
((
"PyThread_allocate_lock() -> %p
\n
"
,
(
void
*
)
lock
));
return
(
PyThread_type_lock
)
lock
;
}
...
...
@@ -521,7 +521,7 @@ PyThread_allocate_lock(void)
}
}
dprintf
((
"PyThread_allocate_lock() -> %p
\n
"
,
lock
));
dprintf
((
"PyThread_allocate_lock() -> %p
\n
"
,
(
void
*
)
lock
));
return
(
PyThread_type_lock
)
lock
;
}
...
...
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