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

Skip to content

Commit 2c7a685

Browse files
committed
Remove code to initialize globals that are never used.
Add some casts to quiet warnings from an unspecified non-GCC compiler. This closes SF patch #436258.
1 parent c32cc7c commit 2c7a685

1 file changed

Lines changed: 11 additions & 22 deletions

File tree

Modules/cPickle.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ LONG Long (unbounded) integer; repr(i), then newline.
127127

128128
static char MARKv = MARK;
129129

130-
/* atol function from string module */
131-
static PyObject *atol_func;
132-
133130
static PyObject *PickleError;
134131
static PyObject *PicklingError;
135132
static PyObject *UnpickleableError;
@@ -145,7 +142,7 @@ static PyObject *__class___str, *__getinitargs___str, *__dict___str,
145142
*__getstate___str, *__setstate___str, *__name___str, *__reduce___str,
146143
*write_str, *__safe_for_unpickling___str, *append_str,
147144
*read_str, *readline_str, *__main___str, *__basicnew___str,
148-
*copy_reg_str, *dispatch_table_str, *safe_constructors_str, *empty_str;
145+
*copy_reg_str, *dispatch_table_str, *safe_constructors_str;
149146

150147
#ifndef PyList_SET_ITEM
151148
#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
@@ -1000,7 +997,8 @@ save_float(Picklerobject *self, PyObject *args) {
1000997
int s, e;
1001998
double f;
1002999
long fhi, flo;
1003-
char str[9], *p = str;
1000+
char str[9];
1001+
unsigned char *p = (unsigned char *)str;
10041002

10051003
*p = BINFLOAT;
10061004
p++;
@@ -1056,31 +1054,31 @@ save_float(Picklerobject *self, PyObject *args) {
10561054
p++;
10571055

10581056
/* Second byte */
1059-
*p = (char) (((e&0xF)<<4) | (fhi>>24));
1057+
*p = (unsigned char) (((e&0xF)<<4) | (fhi>>24));
10601058
p++;
10611059

10621060
/* Third byte */
1063-
*p = (fhi>>16) & 0xFF;
1061+
*p = (unsigned char) ((fhi>>16) & 0xFF);
10641062
p++;
10651063

10661064
/* Fourth byte */
1067-
*p = (fhi>>8) & 0xFF;
1065+
*p = (unsigned char) ((fhi>>8) & 0xFF);
10681066
p++;
10691067

10701068
/* Fifth byte */
1071-
*p = fhi & 0xFF;
1069+
*p = (unsigned char) (fhi & 0xFF);
10721070
p++;
10731071

10741072
/* Sixth byte */
1075-
*p = (flo>>16) & 0xFF;
1073+
*p = (unsigned char) ((flo>>16) & 0xFF);
10761074
p++;
10771075

10781076
/* Seventh byte */
1079-
*p = (flo>>8) & 0xFF;
1077+
*p = (unsigned char) ((flo>>8) & 0xFF);
10801078
p++;
10811079

10821080
/* Eighth byte */
1083-
*p = flo & 0xFF;
1081+
*p = (unsigned char) (flo & 0xFF);
10841082

10851083
if ((*self->write_func)(self, str, 9) < 0)
10861084
return -1;
@@ -4458,7 +4456,7 @@ static struct PyMethodDef cPickle_methods[] = {
44584456

44594457
static int
44604458
init_stuff(PyObject *module_dict) {
4461-
PyObject *string, *copy_reg, *t, *r;
4459+
PyObject *copy_reg, *t, *r;
44624460

44634461
#define INIT_STR(S) UNLESS(S ## _str=PyString_FromString(#S)) return -1;
44644462

@@ -4479,7 +4477,6 @@ init_stuff(PyObject *module_dict) {
44794477
INIT_STR(dispatch_table);
44804478
INIT_STR(safe_constructors);
44814479
INIT_STR(__basicnew__);
4482-
UNLESS (empty_str=PyString_FromString("")) return -1;
44834480

44844481
UNLESS (copy_reg = PyImport_ImportModule("copy_reg"))
44854482
return -1;
@@ -4498,14 +4495,6 @@ init_stuff(PyObject *module_dict) {
44984495

44994496
/* Down to here ********************************** */
45004497

4501-
UNLESS (string = PyImport_ImportModule("string"))
4502-
return -1;
4503-
4504-
UNLESS (atol_func = PyObject_GetAttrString(string, "atol"))
4505-
return -1;
4506-
4507-
Py_DECREF(string);
4508-
45094498
UNLESS (empty_tuple = PyTuple_New(0))
45104499
return -1;
45114500

0 commit comments

Comments
 (0)