Re: [PATCH] libtraceeval: Fix comparing unsigned against zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2 Oct 2023 14:37:15 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> On Mon, 2 Oct 2023 12:31:02 -0600
> Ross Zwisler <zwisler@xxxxxxxxxx> wrote:
> 
> > > @@ -303,14 +303,14 @@ struct traceeval *traceeval_init(struct traceeval_type *keys,
> > >  
> > >  	/* alloc key types */
> > >  	teval->nr_key_types = type_alloc(keys, &teval->key_types);
> > > -	if (teval->nr_key_types <= 0) {
> > > +	if ((ssize_t)teval->nr_key_types <= 0) {    
> > 
> > Rather than casting, wouldn't it be better to just change the type of
> > nr_key_types and nr_val_types to ssize_t?  I think this should be the return
> > type of type_alloc() as well, since this returns -1 on error.  
> 
> I thought about that, and there was a reason against it. But I forgot what
> that was :-p

I still can't remember why I didn't convert ssize_t, so maybe it was not a
real reason. I'll send a v2 changing the type to ssize_t and if there was a
reason I didn't do that before, maybe it will show up when I make the
change!

-- Steve





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux