Skip to content

Commit 98ec915

Browse files
committed
defer cosmetics
1 parent 6ffdd1c commit 98ec915

6 files changed

Lines changed: 30 additions & 35 deletions

File tree

Modules/hashlib.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include "pycore_lock.h" // PyMutex
44

55
/*
6-
* Given a PyObject* 'obj', fill in the Py_buffer* 'viewp' with the result
7-
* of PyObject_GetBuffer. Sets an exception and issues the 'erraction'
8-
* on any errors, e.g., 'return NULL' or 'goto error'.
6+
* Given a PyObject* obj, fill in the Py_buffer* viewp with the result
7+
* of PyObject_GetBuffer. Sets an exception and issues the erraction
8+
* on any errors, e.g. 'return NULL' or 'goto error'.
99
*/
1010
#define GET_BUFFER_VIEW_OR_ERROR(obj, viewp, erraction) do { \
1111
if (PyUnicode_Check((obj))) { \

Modules/hmacmodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,11 @@ _hacl_hmac_state_update(HACL_HMAC_state *state, uint8_t *buf, Py_ssize_t len)
500500

501501
/* Static information used to construct the hash table. */
502502
static const py_hmac_hinfo py_hmac_static_hinfo[] = {
503-
#define Py_HMAC_HINFO_HACL_API(HACL_HID) \
504-
{ \
505-
/* one-shot helpers */ \
506-
.compute = &Py_hmac_## HACL_HID ##_compute_func, \
507-
.compute_py = &_hmac_compute_## HACL_HID ##_impl, \
503+
#define Py_HMAC_HINFO_HACL_API(HACL_HID) \
504+
{ \
505+
/* one-shot helpers */ \
506+
.compute = &Py_hmac_## HACL_HID ##_compute_func, \
507+
.compute_py = &_hmac_compute_## HACL_HID ##_impl, \
508508
}
509509

510510
#define Py_HMAC_HINFO_ENTRY(HACL_HID, HLIB_NAME) \

Modules/md5module.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,14 @@ MD5Type_hexdigest_impl(MD5object *self)
159159
}
160160

161161
static void
162-
_hacl_md5_state_update(Hacl_Hash_MD5_state_t *state,
163-
uint8_t *buf, Py_ssize_t len)
162+
update(Hacl_Hash_MD5_state_t *state, uint8_t *buf, Py_ssize_t len)
164163
{
165-
assert(len >= 0);
166164
/*
167-
* Note: we explicitly ignore the error code on the basis that it would
168-
* take more than 1 billion years to overflow the maximum admissible length
169-
* for MD5 (2^61 - 1).
170-
*/
165+
* Note: we explicitly ignore the error code on the basis that it would
166+
* take more than 1 billion years to overflow the maximum admissible length
167+
* for MD5 (2^61 - 1).
168+
*/
169+
assert(len >= 0);
171170
#if PY_SSIZE_T_MAX > UINT32_MAX
172171
while (len > UINT32_MAX) {
173172
(void)Hacl_Hash_MD5_update(state, buf, UINT32_MAX);
@@ -196,7 +195,7 @@ MD5Type_update_impl(MD5object *self, PyObject *obj)
196195
GET_BUFFER_VIEW_OR_ERROUT(obj, &buf);
197196
HASHLIB_EXTERNAL_INSTRUCTIONS_LOCKED(
198197
self, buf.len,
199-
_hacl_md5_state_update(self->hash_state, buf.buf, buf.len)
198+
update(self->hash_state, buf.buf, buf.len)
200199
);
201200
PyBuffer_Release(&buf);
202201
Py_RETURN_NONE;
@@ -303,7 +302,7 @@ _md5_md5_impl(PyObject *module, PyObject *data, int usedforsecurity,
303302
* where it is not yet possible to have concurrent access. */
304303
HASHLIB_EXTERNAL_INSTRUCTIONS_UNLOCKED(
305304
buf.len,
306-
_hacl_md5_state_update(new->hash_state, buf.buf, buf.len)
305+
update(new->hash_state, buf.buf, buf.len)
307306
);
308307
PyBuffer_Release(&buf);
309308
}

Modules/sha1module.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,7 @@ SHA1Type_hexdigest_impl(SHA1object *self)
162162
}
163163

164164
static void
165-
_hacl_sha1_state_update(Hacl_Hash_SHA1_state_t *state,
166-
uint8_t *buf, Py_ssize_t len)
165+
update(Hacl_Hash_SHA1_state_t *state, uint8_t *buf, Py_ssize_t len)
167166
{
168167
/*
169168
* Note: we explicitly ignore the error code on the basis that it would
@@ -198,7 +197,7 @@ SHA1Type_update_impl(SHA1object *self, PyObject *obj)
198197
GET_BUFFER_VIEW_OR_ERROUT(obj, &buf);
199198
HASHLIB_EXTERNAL_INSTRUCTIONS_LOCKED(
200199
self, buf.len,
201-
_hacl_sha1_state_update(self->hash_state, buf.buf, buf.len)
200+
update(self->hash_state, buf.buf, buf.len)
202201
);
203202
PyBuffer_Release(&buf);
204203
Py_RETURN_NONE;
@@ -304,7 +303,7 @@ _sha1_sha1_impl(PyObject *module, PyObject *data, int usedforsecurity,
304303
* where it is not yet possible to have concurrent access. */
305304
HASHLIB_EXTERNAL_INSTRUCTIONS_UNLOCKED(
306305
buf.len,
307-
_hacl_sha1_state_update(new->hash_state, buf.buf, buf.len)
306+
update(new->hash_state, buf.buf, buf.len)
308307
);
309308
PyBuffer_Release(&buf);
310309
}

Modules/sha2module.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ SHA512_dealloc(PyObject *op)
200200
* 64 bits so we loop in <4gig chunks when needed. */
201201

202202
static void
203-
_hacl_sha2_state_update_256(Hacl_Hash_SHA2_state_t_256 *state,
204-
uint8_t *buf, Py_ssize_t len)
203+
update_256(Hacl_Hash_SHA2_state_t_256 *state, uint8_t *buf, Py_ssize_t len)
205204
{
206205
/*
207206
* Note: we explicitly ignore the error code on the basis that it would
@@ -220,8 +219,7 @@ _hacl_sha2_state_update_256(Hacl_Hash_SHA2_state_t_256 *state,
220219
}
221220

222221
static void
223-
_hacl_sha2_state_update_512(Hacl_Hash_SHA2_state_t_512 *state,
224-
uint8_t *buf, Py_ssize_t len)
222+
update_512(Hacl_Hash_SHA2_state_t_512 *state, uint8_t *buf, Py_ssize_t len)
225223
{
226224
/*
227225
* Note: we explicitly ignore the error code on the basis that it would
@@ -408,7 +406,7 @@ SHA256Type_update_impl(SHA256object *self, PyObject *obj)
408406
GET_BUFFER_VIEW_OR_ERROUT(obj, &buf);
409407
HASHLIB_EXTERNAL_INSTRUCTIONS_LOCKED(
410408
self, buf.len,
411-
_hacl_sha2_state_update_256(self->state, buf.buf, buf.len)
409+
update_256(self->state, buf.buf, buf.len)
412410
);
413411
PyBuffer_Release(&buf);
414412
Py_RETURN_NONE;
@@ -431,7 +429,7 @@ SHA512Type_update_impl(SHA512object *self, PyObject *obj)
431429
GET_BUFFER_VIEW_OR_ERROUT(obj, &buf);
432430
HASHLIB_EXTERNAL_INSTRUCTIONS_LOCKED(
433431
self, buf.len,
434-
_hacl_sha2_state_update_512(self->state, buf.buf, buf.len)
432+
update_512(self->state, buf.buf, buf.len)
435433
);
436434
PyBuffer_Release(&buf);
437435
Py_RETURN_NONE;
@@ -616,7 +614,7 @@ _sha2_sha256_impl(PyObject *module, PyObject *data, int usedforsecurity,
616614
* where it is not yet possible to have concurrent access. */
617615
HASHLIB_EXTERNAL_INSTRUCTIONS_UNLOCKED(
618616
buf.len,
619-
_hacl_sha2_state_update_256(new->state, buf.buf, buf.len)
617+
update_256(new->state, buf.buf, buf.len)
620618
);
621619
PyBuffer_Release(&buf);
622620
}
@@ -674,7 +672,7 @@ _sha2_sha224_impl(PyObject *module, PyObject *data, int usedforsecurity,
674672
* where it is not yet possible to have concurrent access. */
675673
HASHLIB_EXTERNAL_INSTRUCTIONS_UNLOCKED(
676674
buf.len,
677-
_hacl_sha2_state_update_256(new->state, buf.buf, buf.len)
675+
update_256(new->state, buf.buf, buf.len)
678676
);
679677
PyBuffer_Release(&buf);
680678
}
@@ -733,7 +731,7 @@ _sha2_sha512_impl(PyObject *module, PyObject *data, int usedforsecurity,
733731
* where it is not yet possible to have concurrent access. */
734732
HASHLIB_EXTERNAL_INSTRUCTIONS_UNLOCKED(
735733
buf.len,
736-
_hacl_sha2_state_update_512(new->state, buf.buf, buf.len)
734+
update_512(new->state, buf.buf, buf.len)
737735
);
738736
PyBuffer_Release(&buf);
739737
}
@@ -792,7 +790,7 @@ _sha2_sha384_impl(PyObject *module, PyObject *data, int usedforsecurity,
792790
* where it is not yet possible to have concurrent access. */
793791
HASHLIB_EXTERNAL_INSTRUCTIONS_UNLOCKED(
794792
buf.len,
795-
_hacl_sha2_state_update_512(new->state, buf.buf, buf.len)
793+
update_512(new->state, buf.buf, buf.len)
796794
);
797795
PyBuffer_Release(&buf);
798796
}

Modules/sha3module.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ newSHA3object(PyTypeObject *type)
9292
}
9393

9494
static void
95-
_hacl_sha3_state_update(Hacl_Hash_SHA3_state_t *state,
96-
uint8_t *buf, Py_ssize_t len)
95+
sha3_update(Hacl_Hash_SHA3_state_t *state, uint8_t *buf, Py_ssize_t len)
9796
{
9897
/*
9998
* Note: we explicitly ignore the error code on the basis that it would
@@ -176,7 +175,7 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data_obj, int usedforsecurity,
176175
* where it is not yet possible to have concurrent access. */
177176
HASHLIB_EXTERNAL_INSTRUCTIONS_UNLOCKED(
178177
buf.len,
179-
_hacl_sha3_state_update(self->hash_state, buf.buf, buf.len)
178+
sha3_update(self->hash_state, buf.buf, buf.len)
180179
);
181180
}
182181

@@ -311,7 +310,7 @@ _sha3_sha3_224_update_impl(SHA3object *self, PyObject *data)
311310
GET_BUFFER_VIEW_OR_ERROUT(data, &buf);
312311
HASHLIB_EXTERNAL_INSTRUCTIONS_LOCKED(
313312
self, buf.len,
314-
_hacl_sha3_state_update(self->hash_state, buf.buf, buf.len)
313+
sha3_update(self->hash_state, buf.buf, buf.len)
315314
);
316315
PyBuffer_Release(&buf);
317316
Py_RETURN_NONE;

0 commit comments

Comments
 (0)