Re: [PATCH] ksmbd: clean up a type in ksmbd_vfs_stream_write()

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

 



On Fri, Jun 03, 2022 at 08:18:19AM +0900, Namjae Jeon wrote:
> 2022-06-02 19:51 GMT+09:00, Dan Carpenter <dan.carpenter@xxxxxxxxxx>:
> > @@ -428,9 +429,9 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp,
> > char *buf, loff_t *pos,
> >  				       fp->stream.name,
> >  				       fp->stream.size,
> >  				       &stream_buf);
> > -	if ((int)v_len < 0) {
> > +	if (v_len < 0) {
> >  		pr_err("not found stream in xattr : %zd\n", v_len);
> > -		err = (int)v_len;
> > +		err = v_len;
> Data type of ssize_t is long. Wouldn't some static checker warn us
> that this is a problem?

None that I know of.

To a human reader, the cast isn't needed because when a function returns
ssize_t the negatives can only be error codes in the (-4095)-(-1) range.
No other negative sizes make sense.

On the other hand, the "if ((int)v_len < 0) {" line really should
trigger a static checker because there are times when sizes could be
over 2GB.  I will write down that I need to create that checker.

regards,
dan carpenter




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux