From 21dd43c01d6b9cd50512c9ab6d83c97cde3bf115 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Sat, 29 May 2021 01:40:12 +0100 Subject: Fix MSVC compiler warnings in dictobject.c (GH-26432) --- Objects/dictobject.c | 4 ++-- Objects/odictobject.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 65718c2..d97f9e21 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -416,7 +416,7 @@ calculate_log2_keysize(Py_ssize_t minsize) minsize = (minsize | PyDict_MINSIZE) - 1; unsigned long msb; _BitScanReverse64(&msb, (uint64_t)minsize); - return msb + 1; + return (uint8_t)(msb + 1); #else uint8_t log2_size; for (log2_size = PyDict_LOG_MINSIZE; @@ -600,7 +600,7 @@ new_keys_object(uint8_t log2_size) dk->dk_kind = DICT_KEYS_UNICODE; dk->dk_nentries = 0; dk->dk_version = 0; - memset(&dk->dk_indices[0], 0xff, es * (1<dk_indices[0], 0xff, es<od_fast_nodes with a new table matching the size of dict's. */ static int _odict_resize(PyODictObject *od) @@ -553,7 +555,7 @@ _odict_resize(PyODictObject *od) _ODictNode **fast_nodes, *node; /* Initialize a new "fast nodes" table. */ - size = 1 << (((PyDictObject *)od)->ma_keys->dk_log2_size); + size = ONE << (((PyDictObject *)od)->ma_keys->dk_log2_size); fast_nodes = PyMem_NEW(_ODictNode *, size); if (fast_nodes == NULL) { PyErr_NoMemory(); @@ -592,7 +594,7 @@ _odict_get_index(PyODictObject *od, PyObject *key, Py_hash_t hash) /* Ensure od_fast_nodes and dk_entries are in sync. */ if (od->od_resize_sentinel != keys || - od->od_fast_nodes_size != (1 << (keys->dk_log2_size))) { + od->od_fast_nodes_size != (ONE << (keys->dk_log2_size))) { int resize_res = _odict_resize(od); if (resize_res < 0) return -1; -- cgit v0.12