Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1266380

Re: [PATCH V2 2/3] scsi: fix compiler warning for sg

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [PATCH V2 2/3] scsi: fix compiler warning for sg
Date 2015-11-10 11:20 +0100
Message-ID <qtebU-3Kn-19@gated-at.bofh.it> (permalink)
References <qsJUu-88f-9@gated-at.bofh.it> <qt9ce-nP-21@gated-at.bofh.it> <qt9ce-nP-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Monday 09 November 2015 22:53:17 Timur Tabi wrote:
> Sinan Kaya wrote:
> >
> > The code says it is using these macros for small integers only which
> > can't overflow. I was trying to get rid of compiler warning and it seems
> > to have disappeared.
> 
> I would double-check the assembly code, if I were you.  I don't like it 
> when warnings just go away like that.
> 
> Besides, we *should* be using do_div() for 64-bit division.

I stared at this code for some time and couldn't figure out whether it
is actually safe or not. The point here is that it doesn't actually do
a 64-bit division here:

	MULDIV(INT_MAX, USER_HZ, HZ)

where all arguments are 32bit and it tries to figure out whether the
ioctl argument is too big to fit into a 32-bit number

but it does a 'long' division that happens to be 64-bit long on
architectures with the respective register size when it then does

	sfp->timeout = MULDIV (val, HZ, USER_HZ);

to scale up the argument from USER_HZ to the possibly larger in-kernel
HZ value. So I think it's safe as is, but I'm still not entirely sure.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V2 2/3] scsi: fix compiler warning for sg Sinan Kaya <okaya@codeaurora.org> - 2015-11-09 03:00 +0100
  Re: [PATCH V2 2/3] scsi: fix compiler warning for sg Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-11-09 15:20 +0100
    Re: [PATCH V2 2/3] scsi: fix compiler warning for sg Timur Tabi <timur@codeaurora.org> - 2015-11-10 04:30 +0100
      Re: [PATCH V2 2/3] scsi: fix compiler warning for sg Timur Tabi <timur@codeaurora.org> - 2015-11-10 06:00 +0100
        Re: [PATCH V2 2/3] scsi: fix compiler warning for sg Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-11-10 10:30 +0100
        Re: [PATCH V2 2/3] scsi: fix compiler warning for sg Arnd Bergmann <arnd@arndb.de> - 2015-11-10 11:20 +0100
      Re: [PATCH V2 2/3] scsi: fix compiler warning for sg Sinan Kaya <okaya@codeaurora.org> - 2015-11-10 06:00 +0100
    Re: [PATCH V2 2/3] scsi: fix compiler warning for sg Sinan Kaya <okaya@codeaurora.org> - 2015-11-10 04:30 +0100

csiph-web