[Python-Dev] Checking if unsigned int less then zero. (original) (raw)
Dmitriy Tochansky tochansky at tochlab.net
Fri Jun 22 10:09:54 CEST 2012
- Previous message: [Python-Dev] PEP 362 - request for pronouncement
- Next message: [Python-Dev] Checking if unsigned int less then zero.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello! Playing with cpython source, I found some strange strings in socketmodule.c:
if (flowinfo < 0 || flowinfo > 0xfffff) {
PyErr_SetString(
PyExc_OverflowError,
"getsockaddrarg: flowinfo must be 0-1048575.");
return 0;
}
if (flowinfo < 0 || flowinfo > 0xfffff) {
PyErr_SetString(PyExc_OverflowError,
"getsockaddrarg: flowinfo must be 0-1048575.");
return NULL;
}
The flowinfo variable declared few strings above as unsgined int. Is there any practical sense in this check? Seems like gcc just removes this check. I think any compiler will generate code that checks as unsigned, for example in x86 its JAE/JGE. May be this code is for "bad" compilers or exotic arch?
-- Dmitriy
- Previous message: [Python-Dev] PEP 362 - request for pronouncement
- Next message: [Python-Dev] Checking if unsigned int less then zero.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]