Skip to content

Commit 3e5a211

Browse files
committed
revert
1 parent 6f71e34 commit 3e5a211

File tree

1 file changed

+24
-38
lines changed

1 file changed

+24
-38
lines changed

Modules/_struct.c

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ static PyObject *
265265
unpack_halffloat(const char *p, /* start of 2-byte string */
266266
int le) /* true for little-endian, false for big-endian */
267267
{
268-
volatile double x = PyFloat_Unpack2(p, le);
269-
268+
double x = PyFloat_Unpack2(p, le);
270269
if (x == -1.0 && PyErr_Occurred()) {
271270
return NULL;
272271
}
@@ -279,8 +278,7 @@ pack_halffloat(_structmodulestate *state,
279278
PyObject *v, /* value to pack */
280279
int le) /* true for little-endian, false for big-endian */
281280
{
282-
volatile double x = PyFloat_AsDouble(v);
283-
281+
double x = PyFloat_AsDouble(v);
284282
if (x == -1.0 && PyErr_Occurred()) {
285283
PyErr_SetString(state->StructError,
286284
"required argument is not a float");
@@ -293,8 +291,9 @@ static PyObject *
293291
unpack_float(const char *p, /* start of 4-byte string */
294292
int le) /* true for little-endian, false for big-endian */
295293
{
296-
volatile double x = PyFloat_Unpack4(p, le);
294+
double x;
297295

296+
x = PyFloat_Unpack4(p, le);
298297
if (x == -1.0 && PyErr_Occurred())
299298
return NULL;
300299
return PyFloat_FromDouble(x);
@@ -304,8 +303,9 @@ static PyObject *
304303
unpack_double(const char *p, /* start of 8-byte string */
305304
int le) /* true for little-endian, false for big-endian */
306305
{
307-
volatile double x = PyFloat_Unpack8(p, le);
306+
double x;
308307

308+
x = PyFloat_Unpack8(p, le);
309309
if (x == -1.0 && PyErr_Occurred())
310310
return NULL;
311311
return PyFloat_FromDouble(x);
@@ -765,28 +765,26 @@ np_halffloat(_structmodulestate *state, char *p, PyObject *v, const formatdef *f
765765
static int
766766
np_float(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
767767
{
768-
volatile float x = (float)PyFloat_AsDouble(v);
769-
768+
float x = (float)PyFloat_AsDouble(v);
770769
if (x == -1 && PyErr_Occurred()) {
771770
PyErr_SetString(state->StructError,
772771
"required argument is not a float");
773772
return -1;
774773
}
775-
memcpy(p, (void *)&x, sizeof x);
774+
memcpy(p, &x, sizeof x);
776775
return 0;
777776
}
778777

779778
static int
780779
np_double(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
781780
{
782-
volatile double x = PyFloat_AsDouble(v);
783-
781+
double x = PyFloat_AsDouble(v);
784782
if (x == -1 && PyErr_Occurred()) {
785783
PyErr_SetString(state->StructError,
786784
"required argument is not a float");
787785
return -1;
788786
}
789-
memcpy(p, (void *)&x, sizeof(double));
787+
memcpy(p, &x, sizeof(double));
790788
return 0;
791789
}
792790

@@ -991,14 +989,11 @@ bu_double(_structmodulestate *state, const char *p, const formatdef *f)
991989
static PyObject *
992990
bu_float_complex(_structmodulestate *state, const char *p, const formatdef *f)
993991
{
994-
volatile double x = PyFloat_Unpack4(p, 0);
995-
992+
double x = PyFloat_Unpack4(p, 0);
996993
if (x == -1.0 && PyErr_Occurred()) {
997994
return NULL;
998995
}
999-
1000-
volatile double y = PyFloat_Unpack4(p + 4, 0);
1001-
996+
double y = PyFloat_Unpack4(p + 4, 0);
1002997
if (y == -1.0 && PyErr_Occurred()) {
1003998
return NULL;
1004999
}
@@ -1008,14 +1003,13 @@ bu_float_complex(_structmodulestate *state, const char *p, const formatdef *f)
10081003
static PyObject *
10091004
bu_double_complex(_structmodulestate *state, const char *p, const formatdef *f)
10101005
{
1011-
volatile double x = PyFloat_Unpack8(p, 0);
1006+
double x, y;
10121007

1008+
x = PyFloat_Unpack8(p, 0);
10131009
if (x == -1.0 && PyErr_Occurred()) {
10141010
return NULL;
10151011
}
1016-
1017-
volatile double y = PyFloat_Unpack8(p + 8, 0);
1018-
1012+
y = PyFloat_Unpack8(p + 8, 0);
10191013
if (y == -1.0 && PyErr_Occurred()) {
10201014
return NULL;
10211015
}
@@ -1141,8 +1135,7 @@ bp_halffloat(_structmodulestate *state, char *p, PyObject *v, const formatdef *f
11411135
static int
11421136
bp_float(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
11431137
{
1144-
volatile double x = PyFloat_AsDouble(v);
1145-
1138+
double x = PyFloat_AsDouble(v);
11461139
if (x == -1 && PyErr_Occurred()) {
11471140
PyErr_SetString(state->StructError,
11481141
"required argument is not a float");
@@ -1154,8 +1147,7 @@ bp_float(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
11541147
static int
11551148
bp_double(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
11561149
{
1157-
volatile double x = PyFloat_AsDouble(v);
1158-
1150+
double x = PyFloat_AsDouble(v);
11591151
if (x == -1 && PyErr_Occurred()) {
11601152
PyErr_SetString(state->StructError,
11611153
"required argument is not a float");
@@ -1336,14 +1328,11 @@ lu_double(_structmodulestate *state, const char *p, const formatdef *f)
13361328
static PyObject *
13371329
lu_float_complex(_structmodulestate *state, const char *p, const formatdef *f)
13381330
{
1339-
volatile double x = PyFloat_Unpack4(p, 1);
1340-
1331+
double x = PyFloat_Unpack4(p, 1);
13411332
if (x == -1.0 && PyErr_Occurred()) {
13421333
return NULL;
13431334
}
1344-
1345-
volatile double y = PyFloat_Unpack4(p + 4, 1);
1346-
1335+
double y = PyFloat_Unpack4(p + 4, 1);
13471336
if (y == -1.0 && PyErr_Occurred()) {
13481337
return NULL;
13491338
}
@@ -1353,14 +1342,13 @@ lu_float_complex(_structmodulestate *state, const char *p, const formatdef *f)
13531342
static PyObject *
13541343
lu_double_complex(_structmodulestate *state, const char *p, const formatdef *f)
13551344
{
1356-
volatile double x = PyFloat_Unpack8(p, 1);
1345+
double x, y;
13571346

1347+
x = PyFloat_Unpack8(p, 1);
13581348
if (x == -1.0 && PyErr_Occurred()) {
13591349
return NULL;
13601350
}
1361-
1362-
volatile double y = PyFloat_Unpack8(p + 8, 1);
1363-
1351+
y = PyFloat_Unpack8(p + 8, 1);
13641352
if (y == -1.0 && PyErr_Occurred()) {
13651353
return NULL;
13661354
}
@@ -1480,8 +1468,7 @@ lp_halffloat(_structmodulestate *state, char *p, PyObject *v, const formatdef *f
14801468
static int
14811469
lp_float(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
14821470
{
1483-
volatile double x = PyFloat_AsDouble(v);
1484-
1471+
double x = PyFloat_AsDouble(v);
14851472
if (x == -1 && PyErr_Occurred()) {
14861473
PyErr_SetString(state->StructError,
14871474
"required argument is not a float");
@@ -1493,8 +1480,7 @@ lp_float(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
14931480
static int
14941481
lp_double(_structmodulestate *state, char *p, PyObject *v, const formatdef *f)
14951482
{
1496-
volatile double x = PyFloat_AsDouble(v);
1497-
1483+
double x = PyFloat_AsDouble(v);
14981484
if (x == -1 && PyErr_Occurred()) {
14991485
PyErr_SetString(state->StructError,
15001486
"required argument is not a float");

0 commit comments

Comments
 (0)