Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
PyInitConfig_SetInt() uses switch/case
  • Loading branch information
vstinner committed Sep 2, 2024
commit 1d2725879671a0da2c431863e53329592b4aa607
19 changes: 15 additions & 4 deletions 19 Python/initconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -3704,7 +3704,9 @@ PyInitConfig_SetInt(PyInitConfig *config, const char *name, int64_t value)
return -1;
}

if (spec->type == PyConfig_MEMBER_INT) {
switch (spec->type) {
case PyConfig_MEMBER_INT:
{
if (value < (int64_t)INT_MIN || INT_MAX < (int64_t)value) {
initconfig_set_error(config,
"config option value is out of int range");
Expand All @@ -3714,8 +3716,12 @@ PyInitConfig_SetInt(PyInitConfig *config, const char *name, int64_t value)

int *member = raw_member;
*member = int_value;
break;
}
else if (spec->type == PyConfig_MEMBER_UINT || spec->type == PyConfig_MEMBER_BOOL) {

case PyConfig_MEMBER_UINT:
case PyConfig_MEMBER_BOOL:
{
if (value < 0 || UINT_MAX < (int64_t)value) {
initconfig_set_error(config,
"config option value is out of unsigned int range");
Expand All @@ -3725,8 +3731,11 @@ PyInitConfig_SetInt(PyInitConfig *config, const char *name, int64_t value)

int *member = raw_member;
*member = int_value;
break;
}
else if (spec->type == PyConfig_MEMBER_ULONG) {

case PyConfig_MEMBER_ULONG:
{
if (value < 0 || (uint64_t)ULONG_MAX < (uint64_t)value) {
initconfig_set_error(config,
"config option value is out of unsigned long range");
Expand All @@ -3736,8 +3745,10 @@ PyInitConfig_SetInt(PyInitConfig *config, const char *name, int64_t value)

unsigned long *member = raw_member;
*member = ulong_value;
break;
}
else {

default:
initconfig_set_error(config, "config option type is not int");
return -1;
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.