From 5aa8031e5b1f6d4140cc7f16a9e88dd504e004c2 Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Thu, 22 Feb 2024 15:01:06 +0000 Subject: Deploy mate-desktop/python-caja to github.com/mate-desktop/python-caja.git:gh-pages --- .../index.html | 97 +++ .../report-4c482f.html | 736 +++++++++++++++++++++ .../report-53a9a5.html | 736 +++++++++++++++++++++ .../scanview.css | 62 ++ .../sorttable.js | 492 ++++++++++++++ 5 files changed, 2123 insertions(+) create mode 100644 2021-10-13-172159-5551-1@08fffe437485_memory_array/index.html create mode 100644 2021-10-13-172159-5551-1@08fffe437485_memory_array/report-4c482f.html create mode 100644 2021-10-13-172159-5551-1@08fffe437485_memory_array/report-53a9a5.html create mode 100644 2021-10-13-172159-5551-1@08fffe437485_memory_array/scanview.css create mode 100644 2021-10-13-172159-5551-1@08fffe437485_memory_array/sorttable.js (limited to '2021-10-13-172159-5551-1@08fffe437485_memory_array') diff --git a/2021-10-13-172159-5551-1@08fffe437485_memory_array/index.html b/2021-10-13-172159-5551-1@08fffe437485_memory_array/index.html new file mode 100644 index 0000000..9c58a38 --- /dev/null +++ b/2021-10-13-172159-5551-1@08fffe437485_memory_array/index.html @@ -0,0 +1,97 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@b6360d00b20a
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 12.0.1 (Fedora 12.0.1-1.fc34) +
Date:Wed Oct 13 17:21:59 2021
+

Bug Summary

+ + + + +
Bug TypeQuantityDisplay?
All Bugs2
Logic error
Potential unintended use of sizeof() on pointer type2
+

Reports

+ + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Logic errorPotential unintended use of sizeof() on pointer typeabstract.hPyVectorcall_Function801View Report
Logic errorPotential unintended use of sizeof() on pointer typeabstract.hPyVectorcall_Function801View Report
+ + diff --git a/2021-10-13-172159-5551-1@08fffe437485_memory_array/report-4c482f.html b/2021-10-13-172159-5551-1@08fffe437485_memory_array/report-4c482f.html new file mode 100644 index 0000000..ddcf7ea --- /dev/null +++ b/2021-10-13-172159-5551-1@08fffe437485_memory_array/report-4c482f.html @@ -0,0 +1,736 @@ + + + +/usr/include/python3.9/cpython/abstract.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:abstract.h
Warning:line 80, column 46
The code calls sizeof() on a pointer type. This can produce an unexpected result
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name caja-python.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/12.0.1 -D HAVE_CONFIG_H -I . -I .. -I .. -I .. -D G_LOG_DOMAIN="Caja-Python" -D DATADIR="/usr/local/share" -D LIBDIR="/usr/local/lib" -D PYTHON_VERSION="3.9" -D PYTHON_ABIFLAGS="" -D PY_LIB_LOC="/usr/lib64" -I /usr/include/python3.9 -I /usr/include/pygobject-3.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/caja -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/12.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -o /rootdir/html-report/2021-10-13-172159-5551-1 -x c caja-python.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#ifndef Py_CPYTHON_ABSTRACTOBJECT_H
2# error "this header file must not be included directly"
3#endif
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9/* === Object Protocol ================================================== */
10
11#ifdef PY_SSIZE_T_CLEAN
12# define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT
13#endif
14
15/* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
16 format to a Python dictionary ("kwargs" dict).
17
18 The type of kwnames keys is not checked. The final function getting
19 arguments is responsible to check if all keys are strings, for example using
20 PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
21
22 Duplicate keys are merged using the last value. If duplicate keys must raise
23 an exception, the caller is responsible to implement an explicit keys on
24 kwnames. */
25PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyStack_AsDict(
26 PyObject *const *values,
27 PyObject *kwnames);
28
29/* Suggested size (number of positional arguments) for arrays of PyObject*
30 allocated on a C stack to avoid allocating memory on the heap memory. Such
31 array is used to pass positional arguments to call functions of the
32 PyObject_Vectorcall() family.
33
34 The size is chosen to not abuse the C stack and so limit the risk of stack
35 overflow. The size is also chosen to allow using the small stack for most
36 function calls of the Python standard library. On 64-bit CPU, it allocates
37 40 bytes on the stack. */
38#define _PY_FASTCALL_SMALL_STACK5 5
39
40PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _Py_CheckFunctionResult(
41 PyThreadState *tstate,
42 PyObject *callable,
43 PyObject *result,
44 const char *where);
45
46/* === Vectorcall protocol (PEP 590) ============================= */
47
48/* Call callable using tp_call. Arguments are like PyObject_Vectorcall()
49 or PyObject_FastCallDict() (both forms are supported),
50 except that nargs is plainly the number of arguments without flags. */
51PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyObject_MakeTpCall(
52 PyThreadState *tstate,
53 PyObject *callable,
54 PyObject *const *args, Py_ssize_t nargs,
55 PyObject *keywords);
56
57#define PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)) ((size_t)1 << (8 * sizeof(size_t) - 1))
58
59static inline Py_ssize_t
60PyVectorcall_NARGS(size_t n)
61{
62 return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1));
63}
64
65static inline vectorcallfunc
66PyVectorcall_Function(PyObject *callable)
67{
68 PyTypeObject *tp;
69 Py_ssize_t offset;
70 vectorcallfunc ptr;
71
72 assert(callable != NULL)((void) sizeof ((callable != ((void*)0)) ? 1 : 0), __extension__
({ if (callable != ((void*)0)) ; else __assert_fail ("callable != NULL"
, "/usr/include/python3.9/cpython/abstract.h", 72, __extension__
__PRETTY_FUNCTION__); }))
;
73 tp = Py_TYPE(callable)(((PyObject*)(callable))->ob_type);
74 if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL(1UL << 11))) {
75 return NULL((void*)0);
76 }
77 assert(PyCallable_Check(callable))((void) sizeof ((PyCallable_Check(callable)) ? 1 : 0), __extension__
({ if (PyCallable_Check(callable)) ; else __assert_fail ("PyCallable_Check(callable)"
, "/usr/include/python3.9/cpython/abstract.h", 77, __extension__
__PRETTY_FUNCTION__); }))
;
78 offset = tp->tp_vectorcall_offset;
79 assert(offset > 0)((void) sizeof ((offset > 0) ? 1 : 0), __extension__ ({ if
(offset > 0) ; else __assert_fail ("offset > 0", "/usr/include/python3.9/cpython/abstract.h"
, 79, __extension__ __PRETTY_FUNCTION__); }))
;
80 memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
The code calls sizeof() on a pointer type. This can produce an unexpected result
81 return ptr;
82}
83
84/* Call the callable object 'callable' with the "vectorcall" calling
85 convention.
86
87 args is a C array for positional arguments.
88
89 nargsf is the number of positional arguments plus optionally the flag
90 PY_VECTORCALL_ARGUMENTS_OFFSET which means that the caller is allowed to
91 modify args[-1].
92
93 kwnames is a tuple of keyword names. The values of the keyword arguments
94 are stored in "args" after the positional arguments (note that the number
95 of keyword arguments does not change nargsf). kwnames can also be NULL if
96 there are no keyword arguments.
97
98 keywords must only contain strings and all keys must be unique.
99
100 Return the result on success. Raise an exception and return NULL on
101 error. */
102static inline PyObject *
103_PyObject_VectorcallTstate(PyThreadState *tstate, PyObject *callable,
104 PyObject *const *args, size_t nargsf,
105 PyObject *kwnames)
106{
107 vectorcallfunc func;
108 PyObject *res;
109
110 assert(kwnames == NULL || PyTuple_Check(kwnames))((void) sizeof ((kwnames == ((void*)0) || PyType_HasFeature((
((PyObject*)(kwnames))->ob_type), (1UL << 26))) ? 1 :
0), __extension__ ({ if (kwnames == ((void*)0) || PyType_HasFeature
((((PyObject*)(kwnames))->ob_type), (1UL << 26))) ; else
__assert_fail ("kwnames == NULL || PyTuple_Check(kwnames)", "/usr/include/python3.9/cpython/abstract.h"
, 110, __extension__ __PRETTY_FUNCTION__); }))
;
111 assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0)((void) sizeof ((args != ((void*)0) || PyVectorcall_NARGS(nargsf
) == 0) ? 1 : 0), __extension__ ({ if (args != ((void*)0) || PyVectorcall_NARGS
(nargsf) == 0) ; else __assert_fail ("args != NULL || PyVectorcall_NARGS(nargsf) == 0"
, "/usr/include/python3.9/cpython/abstract.h", 111, __extension__
__PRETTY_FUNCTION__); }))
;
112
113 func = PyVectorcall_Function(callable);
114 if (func == NULL((void*)0)) {
115 Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
116 return _PyObject_MakeTpCall(tstate, callable, args, nargs, kwnames);
117 }
118 res = func(callable, args, nargsf, kwnames);
119 return _Py_CheckFunctionResult(tstate, callable, res, NULL((void*)0));
120}
121
122static inline PyObject *
123PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
124 size_t nargsf, PyObject *kwnames)
125{
126 PyThreadState *tstate = PyThreadState_GET()PyThreadState_Get();
127 return _PyObject_VectorcallTstate(tstate, callable,
128 args, nargsf, kwnames);
129}
130
131// Backwards compatibility aliases for API that was provisional in Python 3.8
132#define _PyObject_VectorcallPyObject_Vectorcall PyObject_Vectorcall
133#define _PyObject_VectorcallMethodPyObject_VectorcallMethod PyObject_VectorcallMethod
134#define _PyObject_FastCallDictPyObject_VectorcallDict PyObject_VectorcallDict
135#define _PyVectorcall_FunctionPyVectorcall_Function PyVectorcall_Function
136#define _PyObject_CallOneArgPyObject_CallOneArg PyObject_CallOneArg
137#define _PyObject_CallMethodNoArgsPyObject_CallMethodNoArgs PyObject_CallMethodNoArgs
138#define _PyObject_CallMethodOneArgPyObject_CallMethodOneArg PyObject_CallMethodOneArg
139
140/* Same as PyObject_Vectorcall except that keyword arguments are passed as
141 dict, which may be NULL if there are no keyword arguments. */
142PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * PyObject_VectorcallDict(
143 PyObject *callable,
144 PyObject *const *args,
145 size_t nargsf,
146 PyObject *kwargs);
147
148/* Call "callable" (which must support vectorcall) with positional arguments
149 "tuple" and keyword arguments "dict". "dict" may also be NULL */
150PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
151
152static inline PyObject *
153_PyObject_FastCallTstate(PyThreadState *tstate, PyObject *func, PyObject *const *args, Py_ssize_t nargs)
154{
155 return _PyObject_VectorcallTstate(tstate, func, args, (size_t)nargs, NULL((void*)0));
156}
157
158/* Same as PyObject_Vectorcall except without keyword arguments */
159static inline PyObject *
160_PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs)
161{
162 PyThreadState *tstate = PyThreadState_GET()PyThreadState_Get();
163 return _PyObject_FastCallTstate(tstate, func, args, nargs);
164}
165
166/* Call a callable without any arguments
167 Private static inline function variant of public function
168 PyObject_CallNoArgs(). */
169static inline PyObject *
170_PyObject_CallNoArg(PyObject *func) {
171 PyThreadState *tstate = PyThreadState_GET()PyThreadState_Get();
172 return _PyObject_VectorcallTstate(tstate, func, NULL((void*)0), 0, NULL((void*)0));
173}
174
175static inline PyObject *
176PyObject_CallOneArg(PyObject *func, PyObject *arg)
177{
178 PyObject *_args[2];
179 PyObject **args;
180 PyThreadState *tstate;
181 size_t nargsf;
182
183 assert(arg != NULL)((void) sizeof ((arg != ((void*)0)) ? 1 : 0), __extension__ (
{ if (arg != ((void*)0)) ; else __assert_fail ("arg != NULL",
"/usr/include/python3.9/cpython/abstract.h", 183, __extension__
__PRETTY_FUNCTION__); }))
;
184 args = _args + 1; // For PY_VECTORCALL_ARGUMENTS_OFFSET
185 args[0] = arg;
186 tstate = PyThreadState_GET()PyThreadState_Get();
187 nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1));
188 return _PyObject_VectorcallTstate(tstate, func, args, nargsf, NULL((void*)0));
189}
190
191PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * PyObject_VectorcallMethod(
192 PyObject *name, PyObject *const *args,
193 size_t nargsf, PyObject *kwnames);
194
195static inline PyObject *
196PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
197{
198 return PyObject_VectorcallMethod(name, &self,
199 1 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)), NULL((void*)0));
200}
201
202static inline PyObject *
203PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg)
204{
205 PyObject *args[2] = {self, arg};
206
207 assert(arg != NULL)((void) sizeof ((arg != ((void*)0)) ? 1 : 0), __extension__ (
{ if (arg != ((void*)0)) ; else __assert_fail ("arg != NULL",
"/usr/include/python3.9/cpython/abstract.h", 207, __extension__
__PRETTY_FUNCTION__); }))
;
208 return PyObject_VectorcallMethod(name, args,
209 2 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)), NULL((void*)0));
210}
211
212/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
213 as the method name. */
214PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyObject_CallMethodId(PyObject *obj,
215 _Py_Identifier *name,
216 const char *format, ...);
217
218PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyObject_CallMethodId_SizeT(PyObject *obj,
219 _Py_Identifier *name,
220 const char *format,
221 ...);
222
223PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyObject_CallMethodIdObjArgs(
224 PyObject *obj,
225 struct _Py_Identifier *name,
226 ...);
227
228static inline PyObject *
229_PyObject_VectorcallMethodId(
230 _Py_Identifier *name, PyObject *const *args,
231 size_t nargsf, PyObject *kwnames)
232{
233 PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
234 if (!oname) {
235 return NULL((void*)0);
236 }
237 return PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
238}
239
240static inline PyObject *
241_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
242{
243 return _PyObject_VectorcallMethodId(name, &self,
244 1 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)), NULL((void*)0));
245}
246
247static inline PyObject *
248_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg)
249{
250 PyObject *args[2] = {self, arg};
251
252 assert(arg != NULL)((void) sizeof ((arg != ((void*)0)) ? 1 : 0), __extension__ (
{ if (arg != ((void*)0)) ; else __assert_fail ("arg != NULL",
"/usr/include/python3.9/cpython/abstract.h", 252, __extension__
__PRETTY_FUNCTION__); }))
;
253 return _PyObject_VectorcallMethodId(name, args,
254 2 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)), NULL((void*)0));
255}
256
257PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int _PyObject_HasLen(PyObject *o);
258
259/* Guess the size of object 'o' using len(o) or o.__length_hint__().
260 If neither of those return a non-negative value, then return the default
261 value. If one of the calls fails, this function returns -1. */
262PyAPI_FUNC(Py_ssize_t)__attribute__ ((visibility ("default"))) Py_ssize_t PyObject_LengthHint(PyObject *o, Py_ssize_t);
263
264/* === New Buffer API ============================================ */
265
266/* Return 1 if the getbuffer function is available, otherwise return 0. */
267PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyObject_CheckBuffer(PyObject *obj);
268
269/* This is a C-API version of the getbuffer function call. It checks
270 to make sure object has the required function pointer and issues the
271 call.
272
273 Returns -1 and raises an error on failure and returns 0 on success. */
274PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyObject_GetBuffer(PyObject *obj, Py_buffer *view,
275 int flags);
276
277/* Get the memory area pointed to by the indices for the buffer given.
278 Note that view->ndim is the assumed size of indices. */
279PyAPI_FUNC(void *)__attribute__ ((visibility ("default"))) void * PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices);
280
281/* Return the implied itemsize of the data-format area from a
282 struct-style description. */
283PyAPI_FUNC(Py_ssize_t)__attribute__ ((visibility ("default"))) Py_ssize_t PyBuffer_SizeFromFormat(const char *format);
284
285/* Implementation in memoryobject.c */
286PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyBuffer_ToContiguous(void *buf, Py_buffer *view,
287 Py_ssize_t len, char order);
288
289PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyBuffer_FromContiguous(Py_buffer *view, void *buf,
290 Py_ssize_t len, char order);
291
292/* Copy len bytes of data from the contiguous chunk of memory
293 pointed to by buf into the buffer exported by obj. Return
294 0 on success and return -1 and raise a PyBuffer_Error on
295 error (i.e. the object does not have a buffer interface or
296 it is not working).
297
298 If fort is 'F', then if the object is multi-dimensional,
299 then the data will be copied into the array in
300 Fortran-style (first dimension varies the fastest). If
301 fort is 'C', then the data will be copied into the array
302 in C-style (last dimension varies the fastest). If fort
303 is 'A', then it does not matter and the copy will be made
304 in whatever way is more efficient. */
305PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyObject_CopyData(PyObject *dest, PyObject *src);
306
307/* Copy the data from the src buffer to the buffer of destination. */
308PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyBuffer_IsContiguous(const Py_buffer *view, char fort);
309
310/*Fill the strides array with byte-strides of a contiguous
311 (Fortran-style if fort is 'F' or C-style otherwise)
312 array of the given shape with the given number of bytes
313 per element. */
314PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void PyBuffer_FillContiguousStrides(int ndims,
315 Py_ssize_t *shape,
316 Py_ssize_t *strides,
317 int itemsize,
318 char fort);
319
320/* Fills in a buffer-info structure correctly for an exporter
321 that can only share a contiguous chunk of memory of
322 "unsigned bytes" of the given length.
323
324 Returns 0 on success and -1 (with raising an error) on error. */
325PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,
326 Py_ssize_t len, int readonly,
327 int flags);
328
329/* Releases a Py_buffer obtained from getbuffer ParseTuple's "s*". */
330PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void PyBuffer_Release(Py_buffer *view);
331
332/* ==== Iterators ================================================ */
333
334#define PyIter_Check(obj)((((PyObject*)(obj))->ob_type)->tp_iternext != ((void*)
0) && (((PyObject*)(obj))->ob_type)->tp_iternext
!= &_PyObject_NextNotImplemented)
\
335 (Py_TYPE(obj)(((PyObject*)(obj))->ob_type)->tp_iternext != NULL((void*)0) && \
336 Py_TYPE(obj)(((PyObject*)(obj))->ob_type)->tp_iternext != &_PyObject_NextNotImplemented)
337
338/* === Sequence protocol ================================================ */
339
340/* Assume tp_as_sequence and sq_item exist and that 'i' does not
341 need to be corrected for a negative index. */
342#define PySequence_ITEM(o, i)( (((PyObject*)(o))->ob_type)->tp_as_sequence->sq_item
(o, i) )
\
343 ( Py_TYPE(o)(((PyObject*)(o))->ob_type)->tp_as_sequence->sq_item(o, i) )
344
345#define PY_ITERSEARCH_COUNT1 1
346#define PY_ITERSEARCH_INDEX2 2
347#define PY_ITERSEARCH_CONTAINS3 3
348
349/* Iterate over seq.
350
351 Result depends on the operation:
352
353 PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if
354 error.
355 PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of
356 obj in seq; set ValueError and return -1 if none found;
357 also return -1 on error.
358 PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on
359 error. */
360PyAPI_FUNC(Py_ssize_t)__attribute__ ((visibility ("default"))) Py_ssize_t _PySequence_IterSearch(PyObject *seq,
361 PyObject *obj, int operation);
362
363/* === Mapping protocol ================================================= */
364
365PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
366
367PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
368
369PyAPI_FUNC(char *const *)__attribute__ ((visibility ("default"))) char *const * _PySequence_BytesToCharpArray(PyObject* self);
370
371PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void _Py_FreeCharPArray(char *const array[]);
372
373/* For internal use by buffer API functions */
374PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
375 const Py_ssize_t *shape);
376PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
377 const Py_ssize_t *shape);
378
379/* Convert Python int to Py_ssize_t. Do nothing if the argument is None. */
380PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int _Py_convert_optional_to_ssize_t(PyObject *, void *);
381
382#ifdef __cplusplus
383}
384#endif
diff --git a/2021-10-13-172159-5551-1@08fffe437485_memory_array/report-53a9a5.html b/2021-10-13-172159-5551-1@08fffe437485_memory_array/report-53a9a5.html new file mode 100644 index 0000000..9accf76 --- /dev/null +++ b/2021-10-13-172159-5551-1@08fffe437485_memory_array/report-53a9a5.html @@ -0,0 +1,736 @@ + + + +/usr/include/python3.9/cpython/abstract.h + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:abstract.h
Warning:line 80, column 46
The code calls sizeof() on a pointer type. This can produce an unexpected result
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name caja-python-object.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/12.0.1 -D HAVE_CONFIG_H -I . -I .. -I .. -I .. -D G_LOG_DOMAIN="Caja-Python" -D DATADIR="/usr/local/share" -D LIBDIR="/usr/local/lib" -D PYTHON_VERSION="3.9" -D PYTHON_ABIFLAGS="" -D PY_LIB_LOC="/usr/lib64" -I /usr/include/python3.9 -I /usr/include/pygobject-3.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/caja -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D PIC -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/12.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir /rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -o /rootdir/html-report/2021-10-13-172159-5551-1 -x c caja-python-object.c +
+ + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1#ifndef Py_CPYTHON_ABSTRACTOBJECT_H
2# error "this header file must not be included directly"
3#endif
4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9/* === Object Protocol ================================================== */
10
11#ifdef PY_SSIZE_T_CLEAN
12# define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT
13#endif
14
15/* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
16 format to a Python dictionary ("kwargs" dict).
17
18 The type of kwnames keys is not checked. The final function getting
19 arguments is responsible to check if all keys are strings, for example using
20 PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
21
22 Duplicate keys are merged using the last value. If duplicate keys must raise
23 an exception, the caller is responsible to implement an explicit keys on
24 kwnames. */
25PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyStack_AsDict(
26 PyObject *const *values,
27 PyObject *kwnames);
28
29/* Suggested size (number of positional arguments) for arrays of PyObject*
30 allocated on a C stack to avoid allocating memory on the heap memory. Such
31 array is used to pass positional arguments to call functions of the
32 PyObject_Vectorcall() family.
33
34 The size is chosen to not abuse the C stack and so limit the risk of stack
35 overflow. The size is also chosen to allow using the small stack for most
36 function calls of the Python standard library. On 64-bit CPU, it allocates
37 40 bytes on the stack. */
38#define _PY_FASTCALL_SMALL_STACK5 5
39
40PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _Py_CheckFunctionResult(
41 PyThreadState *tstate,
42 PyObject *callable,
43 PyObject *result,
44 const char *where);
45
46/* === Vectorcall protocol (PEP 590) ============================= */
47
48/* Call callable using tp_call. Arguments are like PyObject_Vectorcall()
49 or PyObject_FastCallDict() (both forms are supported),
50 except that nargs is plainly the number of arguments without flags. */
51PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyObject_MakeTpCall(
52 PyThreadState *tstate,
53 PyObject *callable,
54 PyObject *const *args, Py_ssize_t nargs,
55 PyObject *keywords);
56
57#define PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)) ((size_t)1 << (8 * sizeof(size_t) - 1))
58
59static inline Py_ssize_t
60PyVectorcall_NARGS(size_t n)
61{
62 return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1));
63}
64
65static inline vectorcallfunc
66PyVectorcall_Function(PyObject *callable)
67{
68 PyTypeObject *tp;
69 Py_ssize_t offset;
70 vectorcallfunc ptr;
71
72 assert(callable != NULL)((void) sizeof ((callable != ((void*)0)) ? 1 : 0), __extension__
({ if (callable != ((void*)0)) ; else __assert_fail ("callable != NULL"
, "/usr/include/python3.9/cpython/abstract.h", 72, __extension__
__PRETTY_FUNCTION__); }))
;
73 tp = Py_TYPE(callable)(((PyObject*)(callable))->ob_type);
74 if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL(1UL << 11))) {
75 return NULL((void*)0);
76 }
77 assert(PyCallable_Check(callable))((void) sizeof ((PyCallable_Check(callable)) ? 1 : 0), __extension__
({ if (PyCallable_Check(callable)) ; else __assert_fail ("PyCallable_Check(callable)"
, "/usr/include/python3.9/cpython/abstract.h", 77, __extension__
__PRETTY_FUNCTION__); }))
;
78 offset = tp->tp_vectorcall_offset;
79 assert(offset > 0)((void) sizeof ((offset > 0) ? 1 : 0), __extension__ ({ if
(offset > 0) ; else __assert_fail ("offset > 0", "/usr/include/python3.9/cpython/abstract.h"
, 79, __extension__ __PRETTY_FUNCTION__); }))
;
80 memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
The code calls sizeof() on a pointer type. This can produce an unexpected result
81 return ptr;
82}
83
84/* Call the callable object 'callable' with the "vectorcall" calling
85 convention.
86
87 args is a C array for positional arguments.
88
89 nargsf is the number of positional arguments plus optionally the flag
90 PY_VECTORCALL_ARGUMENTS_OFFSET which means that the caller is allowed to
91 modify args[-1].
92
93 kwnames is a tuple of keyword names. The values of the keyword arguments
94 are stored in "args" after the positional arguments (note that the number
95 of keyword arguments does not change nargsf). kwnames can also be NULL if
96 there are no keyword arguments.
97
98 keywords must only contain strings and all keys must be unique.
99
100 Return the result on success. Raise an exception and return NULL on
101 error. */
102static inline PyObject *
103_PyObject_VectorcallTstate(PyThreadState *tstate, PyObject *callable,
104 PyObject *const *args, size_t nargsf,
105 PyObject *kwnames)
106{
107 vectorcallfunc func;
108 PyObject *res;
109
110 assert(kwnames == NULL || PyTuple_Check(kwnames))((void) sizeof ((kwnames == ((void*)0) || PyType_HasFeature((
((PyObject*)(kwnames))->ob_type), (1UL << 26))) ? 1 :
0), __extension__ ({ if (kwnames == ((void*)0) || PyType_HasFeature
((((PyObject*)(kwnames))->ob_type), (1UL << 26))) ; else
__assert_fail ("kwnames == NULL || PyTuple_Check(kwnames)", "/usr/include/python3.9/cpython/abstract.h"
, 110, __extension__ __PRETTY_FUNCTION__); }))
;
111 assert(args != NULL || PyVectorcall_NARGS(nargsf) == 0)((void) sizeof ((args != ((void*)0) || PyVectorcall_NARGS(nargsf
) == 0) ? 1 : 0), __extension__ ({ if (args != ((void*)0) || PyVectorcall_NARGS
(nargsf) == 0) ; else __assert_fail ("args != NULL || PyVectorcall_NARGS(nargsf) == 0"
, "/usr/include/python3.9/cpython/abstract.h", 111, __extension__
__PRETTY_FUNCTION__); }))
;
112
113 func = PyVectorcall_Function(callable);
114 if (func == NULL((void*)0)) {
115 Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
116 return _PyObject_MakeTpCall(tstate, callable, args, nargs, kwnames);
117 }
118 res = func(callable, args, nargsf, kwnames);
119 return _Py_CheckFunctionResult(tstate, callable, res, NULL((void*)0));
120}
121
122static inline PyObject *
123PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
124 size_t nargsf, PyObject *kwnames)
125{
126 PyThreadState *tstate = PyThreadState_GET()PyThreadState_Get();
127 return _PyObject_VectorcallTstate(tstate, callable,
128 args, nargsf, kwnames);
129}
130
131// Backwards compatibility aliases for API that was provisional in Python 3.8
132#define _PyObject_VectorcallPyObject_Vectorcall PyObject_Vectorcall
133#define _PyObject_VectorcallMethodPyObject_VectorcallMethod PyObject_VectorcallMethod
134#define _PyObject_FastCallDictPyObject_VectorcallDict PyObject_VectorcallDict
135#define _PyVectorcall_FunctionPyVectorcall_Function PyVectorcall_Function
136#define _PyObject_CallOneArgPyObject_CallOneArg PyObject_CallOneArg
137#define _PyObject_CallMethodNoArgsPyObject_CallMethodNoArgs PyObject_CallMethodNoArgs
138#define _PyObject_CallMethodOneArgPyObject_CallMethodOneArg PyObject_CallMethodOneArg
139
140/* Same as PyObject_Vectorcall except that keyword arguments are passed as
141 dict, which may be NULL if there are no keyword arguments. */
142PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * PyObject_VectorcallDict(
143 PyObject *callable,
144 PyObject *const *args,
145 size_t nargsf,
146 PyObject *kwargs);
147
148/* Call "callable" (which must support vectorcall) with positional arguments
149 "tuple" and keyword arguments "dict". "dict" may also be NULL */
150PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
151
152static inline PyObject *
153_PyObject_FastCallTstate(PyThreadState *tstate, PyObject *func, PyObject *const *args, Py_ssize_t nargs)
154{
155 return _PyObject_VectorcallTstate(tstate, func, args, (size_t)nargs, NULL((void*)0));
156}
157
158/* Same as PyObject_Vectorcall except without keyword arguments */
159static inline PyObject *
160_PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs)
161{
162 PyThreadState *tstate = PyThreadState_GET()PyThreadState_Get();
163 return _PyObject_FastCallTstate(tstate, func, args, nargs);
164}
165
166/* Call a callable without any arguments
167 Private static inline function variant of public function
168 PyObject_CallNoArgs(). */
169static inline PyObject *
170_PyObject_CallNoArg(PyObject *func) {
171 PyThreadState *tstate = PyThreadState_GET()PyThreadState_Get();
172 return _PyObject_VectorcallTstate(tstate, func, NULL((void*)0), 0, NULL((void*)0));
173}
174
175static inline PyObject *
176PyObject_CallOneArg(PyObject *func, PyObject *arg)
177{
178 PyObject *_args[2];
179 PyObject **args;
180 PyThreadState *tstate;
181 size_t nargsf;
182
183 assert(arg != NULL)((void) sizeof ((arg != ((void*)0)) ? 1 : 0), __extension__ (
{ if (arg != ((void*)0)) ; else __assert_fail ("arg != NULL",
"/usr/include/python3.9/cpython/abstract.h", 183, __extension__
__PRETTY_FUNCTION__); }))
;
184 args = _args + 1; // For PY_VECTORCALL_ARGUMENTS_OFFSET
185 args[0] = arg;
186 tstate = PyThreadState_GET()PyThreadState_Get();
187 nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1));
188 return _PyObject_VectorcallTstate(tstate, func, args, nargsf, NULL((void*)0));
189}
190
191PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * PyObject_VectorcallMethod(
192 PyObject *name, PyObject *const *args,
193 size_t nargsf, PyObject *kwnames);
194
195static inline PyObject *
196PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
197{
198 return PyObject_VectorcallMethod(name, &self,
199 1 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)), NULL((void*)0));
200}
201
202static inline PyObject *
203PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg)
204{
205 PyObject *args[2] = {self, arg};
206
207 assert(arg != NULL)((void) sizeof ((arg != ((void*)0)) ? 1 : 0), __extension__ (
{ if (arg != ((void*)0)) ; else __assert_fail ("arg != NULL",
"/usr/include/python3.9/cpython/abstract.h", 207, __extension__
__PRETTY_FUNCTION__); }))
;
208 return PyObject_VectorcallMethod(name, args,
209 2 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)), NULL((void*)0));
210}
211
212/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
213 as the method name. */
214PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyObject_CallMethodId(PyObject *obj,
215 _Py_Identifier *name,
216 const char *format, ...);
217
218PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyObject_CallMethodId_SizeT(PyObject *obj,
219 _Py_Identifier *name,
220 const char *format,
221 ...);
222
223PyAPI_FUNC(PyObject *)__attribute__ ((visibility ("default"))) PyObject * _PyObject_CallMethodIdObjArgs(
224 PyObject *obj,
225 struct _Py_Identifier *name,
226 ...);
227
228static inline PyObject *
229_PyObject_VectorcallMethodId(
230 _Py_Identifier *name, PyObject *const *args,
231 size_t nargsf, PyObject *kwnames)
232{
233 PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
234 if (!oname) {
235 return NULL((void*)0);
236 }
237 return PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
238}
239
240static inline PyObject *
241_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
242{
243 return _PyObject_VectorcallMethodId(name, &self,
244 1 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)), NULL((void*)0));
245}
246
247static inline PyObject *
248_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg)
249{
250 PyObject *args[2] = {self, arg};
251
252 assert(arg != NULL)((void) sizeof ((arg != ((void*)0)) ? 1 : 0), __extension__ (
{ if (arg != ((void*)0)) ; else __assert_fail ("arg != NULL",
"/usr/include/python3.9/cpython/abstract.h", 252, __extension__
__PRETTY_FUNCTION__); }))
;
253 return _PyObject_VectorcallMethodId(name, args,
254 2 | PY_VECTORCALL_ARGUMENTS_OFFSET((size_t)1 << (8 * sizeof(size_t) - 1)), NULL((void*)0));
255}
256
257PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int _PyObject_HasLen(PyObject *o);
258
259/* Guess the size of object 'o' using len(o) or o.__length_hint__().
260 If neither of those return a non-negative value, then return the default
261 value. If one of the calls fails, this function returns -1. */
262PyAPI_FUNC(Py_ssize_t)__attribute__ ((visibility ("default"))) Py_ssize_t PyObject_LengthHint(PyObject *o, Py_ssize_t);
263
264/* === New Buffer API ============================================ */
265
266/* Return 1 if the getbuffer function is available, otherwise return 0. */
267PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyObject_CheckBuffer(PyObject *obj);
268
269/* This is a C-API version of the getbuffer function call. It checks
270 to make sure object has the required function pointer and issues the
271 call.
272
273 Returns -1 and raises an error on failure and returns 0 on success. */
274PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyObject_GetBuffer(PyObject *obj, Py_buffer *view,
275 int flags);
276
277/* Get the memory area pointed to by the indices for the buffer given.
278 Note that view->ndim is the assumed size of indices. */
279PyAPI_FUNC(void *)__attribute__ ((visibility ("default"))) void * PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices);
280
281/* Return the implied itemsize of the data-format area from a
282 struct-style description. */
283PyAPI_FUNC(Py_ssize_t)__attribute__ ((visibility ("default"))) Py_ssize_t PyBuffer_SizeFromFormat(const char *format);
284
285/* Implementation in memoryobject.c */
286PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyBuffer_ToContiguous(void *buf, Py_buffer *view,
287 Py_ssize_t len, char order);
288
289PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyBuffer_FromContiguous(Py_buffer *view, void *buf,
290 Py_ssize_t len, char order);
291
292/* Copy len bytes of data from the contiguous chunk of memory
293 pointed to by buf into the buffer exported by obj. Return
294 0 on success and return -1 and raise a PyBuffer_Error on
295 error (i.e. the object does not have a buffer interface or
296 it is not working).
297
298 If fort is 'F', then if the object is multi-dimensional,
299 then the data will be copied into the array in
300 Fortran-style (first dimension varies the fastest). If
301 fort is 'C', then the data will be copied into the array
302 in C-style (last dimension varies the fastest). If fort
303 is 'A', then it does not matter and the copy will be made
304 in whatever way is more efficient. */
305PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyObject_CopyData(PyObject *dest, PyObject *src);
306
307/* Copy the data from the src buffer to the buffer of destination. */
308PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyBuffer_IsContiguous(const Py_buffer *view, char fort);
309
310/*Fill the strides array with byte-strides of a contiguous
311 (Fortran-style if fort is 'F' or C-style otherwise)
312 array of the given shape with the given number of bytes
313 per element. */
314PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void PyBuffer_FillContiguousStrides(int ndims,
315 Py_ssize_t *shape,
316 Py_ssize_t *strides,
317 int itemsize,
318 char fort);
319
320/* Fills in a buffer-info structure correctly for an exporter
321 that can only share a contiguous chunk of memory of
322 "unsigned bytes" of the given length.
323
324 Returns 0 on success and -1 (with raising an error) on error. */
325PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,
326 Py_ssize_t len, int readonly,
327 int flags);
328
329/* Releases a Py_buffer obtained from getbuffer ParseTuple's "s*". */
330PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void PyBuffer_Release(Py_buffer *view);
331
332/* ==== Iterators ================================================ */
333
334#define PyIter_Check(obj)((((PyObject*)(obj))->ob_type)->tp_iternext != ((void*)
0) && (((PyObject*)(obj))->ob_type)->tp_iternext
!= &_PyObject_NextNotImplemented)
\
335 (Py_TYPE(obj)(((PyObject*)(obj))->ob_type)->tp_iternext != NULL((void*)0) && \
336 Py_TYPE(obj)(((PyObject*)(obj))->ob_type)->tp_iternext != &_PyObject_NextNotImplemented)
337
338/* === Sequence protocol ================================================ */
339
340/* Assume tp_as_sequence and sq_item exist and that 'i' does not
341 need to be corrected for a negative index. */
342#define PySequence_ITEM(o, i)( (((PyObject*)(o))->ob_type)->tp_as_sequence->sq_item
(o, i) )
\
343 ( Py_TYPE(o)(((PyObject*)(o))->ob_type)->tp_as_sequence->sq_item(o, i) )
344
345#define PY_ITERSEARCH_COUNT1 1
346#define PY_ITERSEARCH_INDEX2 2
347#define PY_ITERSEARCH_CONTAINS3 3
348
349/* Iterate over seq.
350
351 Result depends on the operation:
352
353 PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if
354 error.
355 PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of
356 obj in seq; set ValueError and return -1 if none found;
357 also return -1 on error.
358 PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on
359 error. */
360PyAPI_FUNC(Py_ssize_t)__attribute__ ((visibility ("default"))) Py_ssize_t _PySequence_IterSearch(PyObject *seq,
361 PyObject *obj, int operation);
362
363/* === Mapping protocol ================================================= */
364
365PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
366
367PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
368
369PyAPI_FUNC(char *const *)__attribute__ ((visibility ("default"))) char *const * _PySequence_BytesToCharpArray(PyObject* self);
370
371PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void _Py_FreeCharPArray(char *const array[]);
372
373/* For internal use by buffer API functions */
374PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
375 const Py_ssize_t *shape);
376PyAPI_FUNC(void)__attribute__ ((visibility ("default"))) void _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
377 const Py_ssize_t *shape);
378
379/* Convert Python int to Py_ssize_t. Do nothing if the argument is None. */
380PyAPI_FUNC(int)__attribute__ ((visibility ("default"))) int _Py_convert_optional_to_ssize_t(PyObject *, void *);
381
382#ifdef __cplusplus
383}
384#endif
diff --git a/2021-10-13-172159-5551-1@08fffe437485_memory_array/scanview.css b/2021-10-13-172159-5551-1@08fffe437485_memory_array/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2021-10-13-172159-5551-1@08fffe437485_memory_array/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2021-10-13-172159-5551-1@08fffe437485_memory_array/sorttable.js b/2021-10-13-172159-5551-1@08fffe437485_memory_array/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2021-10-13-172159-5551-1@08fffe437485_memory_array/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write("