[Python-Dev] Re: [Python-checkins] CVS: python/dist/src/Modules structmodule.c,2.38,2.39

Trent Mick trentm@ActiveState.com
Fri, 15 Sep 2000 08:30:28 -0700


On Fri, Sep 15, 2000 at 12:32:01AM -0700, Martin v. L÷wis wrote:
> Modified Files:
> 	structmodule.c 
> Log Message:
> Check range for bytes and shorts. Closes bug #110845.
> 
> 
> + 	if (x < -32768 || x > 32767){
> + 		PyErr_SetString(StructError,
> + 				"short format requires -32768<=number<=32767");
> + 		return -1;
> + 	}

Would it not be cleaner to use SHRT_MIN and SHRT_MAX (from limits.h I think)
here?

> + 	if (x < 0 || x > 65535){
> + 		PyErr_SetString(StructError,
> + 				"short format requires 0<=number<=65535");
> + 		return -1;
> + 	}
> + 	* (unsigned short *)p = (unsigned short)x;

And USHRT_MIN and USHRT_MAX here?


No biggie though.

Trent

-- 
Trent Mick
TrentM@ActiveState.com