[Bf-blender-cvs] [89dca47] framebuffer: Remove range checks for gpu.offscreen.new

Campbell Barton noreply at git.blender.org
Tue Oct 20 04:48:22 CEST 2015


Commit: 89dca4796f1540b88ea52a2bde567646906e8652
Author: Campbell Barton
Date:   Tue Oct 20 13:41:02 2015 +1100
Branches: framebuffer
https://developer.blender.org/rB89dca4796f1540b88ea52a2bde567646906e8652

Remove range checks for gpu.offscreen.new

Check non-negative still allows zero height, or INT_MAX... just let OpenGL handle the error case.

===================================================================

M	source/blender/python/intern/gpu_offscreen.c

===================================================================

diff --git a/source/blender/python/intern/gpu_offscreen.c b/source/blender/python/intern/gpu_offscreen.c
index cd9824f..1f3a81d 100644
--- a/source/blender/python/intern/gpu_offscreen.c
+++ b/source/blender/python/intern/gpu_offscreen.c
@@ -79,9 +79,6 @@ static int bpy_gpu_offscreen_valid_check(BPy_GPUOffScreen *py_gpu_ofs)
 	} \
 } ((void)0)
 
-/* annoying since arg parsing won't check overflow */
-#define UINT_IS_NEG(n) ((n) > INT_MAX)
-
 PyDoc_STRVAR(pygpu_offscreen_width_doc, "Texture width.\n\n:type: int");
 static PyObject *pygpu_offscreen_width_get(BPy_GPUOffScreen *self, void *UNUSED(type))
 {
@@ -371,7 +368,7 @@ static PyObject *pygpu_offscreen_new(PyObject *UNUSED(self), PyObject *args, PyO
 	static const char *kwlist[] = {"width", "height", "samples", NULL};
 
 	GPUOffScreen *ofs;
-	unsigned int width, height, samples = 0;
+	int width, height, samples = 0;
 	char err_out[256];
 
 	if (!PyArg_ParseTupleAndKeywords(
@@ -381,21 +378,6 @@ static PyObject *pygpu_offscreen_new(PyObject *UNUSED(self), PyObject *args, PyO
 		return NULL;
 	}
 
-	if (UINT_IS_NEG(width)) {
-		PyErr_SetString(PyExc_ValueError, "negative 'width' given");
-		return NULL;
-	}
-
-	if (UINT_IS_NEG(height)) {
-		PyErr_SetString(PyExc_ValueError, "negative 'height' given");
-		return NULL;
-	}
-
-	if (UINT_IS_NEG(samples)) {
-		PyErr_SetString(PyExc_ValueError, "negative 'samples' given");
-		return NULL;
-	}
-
 	ofs = GPU_offscreen_create(width, height, samples, err_out);
 
 	if (ofs == NULL) {
@@ -449,5 +431,4 @@ PyObject *BPyInit_gpu_offscreen(void)
 	return submodule;
 }
 
-#undef UINT_IS_NEG
 #undef BPY_GPU_OFFSCREEN_CHECK_OBJ




More information about the Bf-blender-cvs mailing list