[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:35:19 -0700
On Fri, Sep 15, 2000 at 08:30:28AM -0700, Trent Mick wrote:
> 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?
>
Heh, heh. I jump a bit quickly on that one. Three checkin messages later this
suggestion was applied. :) SOrry about that, Martin.
Trent
--
Trent Mick
TrentM@ActiveState.com