Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3b6448f

Browse files
committed
ANSIfication: add proper prototypes to function-pointers and declarations.
Also, fix a bug found by said declarations, where a string was defined as unsigned char*, but used as signed.
1 parent 2c46eaf commit 3b6448f

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

Modules/cPickle.c

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ Pdata_popList(Pdata *self, int start) {
310310
} \
311311
}
312312

313-
typedef struct {
313+
typedef struct Picklerobject {
314314
PyObject_HEAD
315315
FILE *fp;
316316
PyObject *write;
@@ -321,15 +321,15 @@ typedef struct {
321321
PyObject *inst_pers_func;
322322
int bin;
323323
int fast; /* Fast mode doesn't save in memo, don't use if circ ref */
324-
int (*write_func)();
324+
int (*write_func)(struct Picklerobject *, char *, int);
325325
char *write_buf;
326326
int buf_size;
327327
PyObject *dispatch_table;
328328
} Picklerobject;
329329

330330
staticforward PyTypeObject Picklertype;
331331

332-
typedef struct {
332+
typedef struct Unpicklerobject {
333333
PyObject_HEAD
334334
FILE *fp;
335335
PyObject *file;
@@ -344,8 +344,8 @@ typedef struct {
344344
int *marks;
345345
int num_marks;
346346
int marks_size;
347-
int (*read_func)();
348-
int (*readline_func)();
347+
int (*read_func)(struct Unpicklerobject *, char **, int);
348+
int (*readline_func)(struct Unpicklerobject *, char **);
349349
int buf_size;
350350
char *buf;
351351
PyObject *safe_constructors;
@@ -369,25 +369,11 @@ cPickle_PyMapping_HasKey(PyObject *o, PyObject *key) {
369369

370370
static
371371
PyObject *
372-
#ifdef HAVE_STDARG_PROTOTYPES
373-
/* VARARGS 2 */
374-
cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...) {
375-
#else
376-
/* VARARGS */
377-
cPickle_ErrFormat(va_alist) va_dcl {
378-
#endif
372+
cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...)
373+
{
379374
va_list va;
380375
PyObject *args=0, *retval=0;
381-
#ifdef HAVE_STDARG_PROTOTYPES
382376
va_start(va, format);
383-
#else
384-
PyObject *ErrType;
385-
char *stringformat, *format;
386-
va_start(va);
387-
ErrType = va_arg(va, PyObject *);
388-
stringformat = va_arg(va, char *);
389-
format = va_arg(va, char *);
390-
#endif
391377

392378
if (format) args = Py_VaBuildValue(format, va);
393379
va_end(va);
@@ -3203,7 +3189,8 @@ load_binget(Unpicklerobject *self) {
32033189
static int
32043190
load_long_binget(Unpicklerobject *self) {
32053191
PyObject *py_key = 0, *value = 0;
3206-
unsigned char c, *s;
3192+
unsigned char c;
3193+
char *s;
32073194
long key;
32083195
int rc;
32093196

@@ -3254,7 +3241,8 @@ load_put(Unpicklerobject *self) {
32543241
static int
32553242
load_binput(Unpicklerobject *self) {
32563243
PyObject *py_key = 0, *value = 0;
3257-
unsigned char key, *s;
3244+
unsigned char key;
3245+
char *s;
32583246
int len;
32593247

32603248
if ((*self->read_func)(self, &s, 1) < 0) return -1;
@@ -3274,7 +3262,8 @@ static int
32743262
load_long_binput(Unpicklerobject *self) {
32753263
PyObject *py_key = 0, *value = 0;
32763264
long key;
3277-
unsigned char c, *s;
3265+
unsigned char c;
3266+
char *s;
32783267
int len;
32793268

32803269
if ((*self->read_func)(self, &s, 4) < 0) return -1;

0 commit comments

Comments
 (0)