mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	C++ compiler cleanup: bunch-o-casts, plus use of unsigned loop index var in a couple places
This commit is contained in:
		
							parent
							
								
									3fca463627
								
							
						
					
					
						commit
						429433b30b
					
				
					 6 changed files with 29 additions and 28 deletions
				
			
		|  | @ -255,18 +255,18 @@ PyInt_AsUnsignedLongMask(register PyObject *op) | |||
| 	if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL || | ||||
| 	    nb->nb_int == NULL) { | ||||
| 		PyErr_SetString(PyExc_TypeError, "an integer is required"); | ||||
| 		return -1; | ||||
| 		return (unsigned long)-1; | ||||
| 	} | ||||
| 
 | ||||
| 	io = (PyIntObject*) (*nb->nb_int) (op); | ||||
| 	if (io == NULL) | ||||
| 		return -1; | ||||
| 		return (unsigned long)-1; | ||||
| 	if (!PyInt_Check(io)) { | ||||
| 		if (PyLong_Check(io)) { | ||||
| 			val = PyLong_AsUnsignedLongMask((PyObject *)io); | ||||
| 			Py_DECREF(io); | ||||
| 			if (PyErr_Occurred()) | ||||
| 				return -1; | ||||
| 				return (unsigned long)-1; | ||||
| 			return val; | ||||
| 		} | ||||
| 		else | ||||
|  | @ -274,7 +274,7 @@ PyInt_AsUnsignedLongMask(register PyObject *op) | |||
| 			Py_DECREF(io); | ||||
| 			PyErr_SetString(PyExc_TypeError, | ||||
| 					"nb_int should return int object"); | ||||
| 			return -1; | ||||
| 			return (unsigned long)-1; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | @ -300,18 +300,18 @@ PyInt_AsUnsignedLongLongMask(register PyObject *op) | |||
| 	if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL || | ||||
| 	    nb->nb_int == NULL) { | ||||
| 		PyErr_SetString(PyExc_TypeError, "an integer is required"); | ||||
| 		return -1; | ||||
| 		return (unsigned PY_LONG_LONG)-1; | ||||
| 	} | ||||
| 
 | ||||
| 	io = (PyIntObject*) (*nb->nb_int) (op); | ||||
| 	if (io == NULL) | ||||
| 		return -1; | ||||
| 		return (unsigned PY_LONG_LONG)-1; | ||||
| 	if (!PyInt_Check(io)) { | ||||
| 		if (PyLong_Check(io)) { | ||||
| 			val = PyLong_AsUnsignedLongLongMask((PyObject *)io); | ||||
| 			Py_DECREF(io); | ||||
| 			if (PyErr_Occurred()) | ||||
| 				return -1; | ||||
| 				return (unsigned PY_LONG_LONG)-1; | ||||
| 			return val; | ||||
| 		} | ||||
| 		else | ||||
|  | @ -319,7 +319,7 @@ PyInt_AsUnsignedLongLongMask(register PyObject *op) | |||
| 			Py_DECREF(io); | ||||
| 			PyErr_SetString(PyExc_TypeError, | ||||
| 					"nb_int should return int object"); | ||||
| 			return -1; | ||||
| 			return (unsigned PY_LONG_LONG)-1; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | @ -1152,6 +1152,7 @@ PyInt_Fini(void) | |||
| 	PyIntObject *p; | ||||
| 	PyIntBlock *list, *next; | ||||
| 	int i; | ||||
| 	unsigned int ctr; | ||||
| 	int bc, bf;	/* block count, number of freed blocks */ | ||||
| 	int irem, isum;	/* remaining unfreed ints per block, total */ | ||||
| 
 | ||||
|  | @ -1174,9 +1175,9 @@ PyInt_Fini(void) | |||
| 	while (list != NULL) { | ||||
| 		bc++; | ||||
| 		irem = 0; | ||||
| 		for (i = 0, p = &list->objects[0]; | ||||
| 		     i < N_INTOBJECTS; | ||||
| 		     i++, p++) { | ||||
| 		for (ctr = 0, p = &list->objects[0]; | ||||
| 		     ctr < N_INTOBJECTS; | ||||
| 		     ctr++, p++) { | ||||
| 			if (PyInt_CheckExact(p) && p->ob_refcnt != 0) | ||||
| 				irem++; | ||||
| 		} | ||||
|  | @ -1184,9 +1185,9 @@ PyInt_Fini(void) | |||
| 		if (irem) { | ||||
| 			list->next = block_list; | ||||
| 			block_list = list; | ||||
| 			for (i = 0, p = &list->objects[0]; | ||||
| 			     i < N_INTOBJECTS; | ||||
| 			     i++, p++) { | ||||
| 			for (ctr = 0, p = &list->objects[0]; | ||||
| 			     ctr < N_INTOBJECTS; | ||||
| 			     ctr++, p++) { | ||||
| 				if (!PyInt_CheckExact(p) || | ||||
| 				    p->ob_refcnt == 0) { | ||||
| 					p->ob_type = (struct _typeobject *) | ||||
|  | @ -1227,9 +1228,9 @@ PyInt_Fini(void) | |||
| 	if (Py_VerboseFlag > 1) { | ||||
| 		list = block_list; | ||||
| 		while (list != NULL) { | ||||
| 			for (i = 0, p = &list->objects[0]; | ||||
| 			     i < N_INTOBJECTS; | ||||
| 			     i++, p++) { | ||||
| 			for (ctr = 0, p = &list->objects[0]; | ||||
| 			     ctr < N_INTOBJECTS; | ||||
| 			     ctr++, p++) { | ||||
| 				if (PyInt_CheckExact(p) && p->ob_refcnt != 0) | ||||
| 					/* XXX(twouters) cast refcount to
 | ||||
| 					   long until %zd is universally | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Skip Montanaro
						Skip Montanaro